Skip to content

Instantly share code, notes, and snippets.

@thor48
Created April 25, 2014 14:29
Show Gist options
  • Save thor48/11291532 to your computer and use it in GitHub Desktop.
Save thor48/11291532 to your computer and use it in GitHub Desktop.
SQL find and replace Query
UPDATE `wp_posts`
SET `post_content` = replace(post_content, '/testing/', '/')
WHERE `post_content` LIKE '%/testing/%'
In this example we find any text named '/testing/' and replace it with '/' within table wp_posts in column post_content
@thor48
Copy link
Author

thor48 commented May 4, 2015

MySQL Run SQL Queries From A Shell Prompt / Command Line

mysql -u user -p -e 'SQL Query' database

Where,
-u : Specify mysql database user name
-p : Prompt for password
-e : Execute sql query
database : Specify database name
To list all database, enter:
$ mysql -u vivek -p -e 'show databases;'
To list count all rows, enter:
$ mysql -u vivek -p -e 'SELECT COUNT(*) FROM quotes' cbzquotes
Sample output:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment