MySQL Queries
A few of MySQL queries every WordPress developer should be familiar with...
Permissions
Changing the post title
update wp_posts set post_title =
replace(post_title, ‘Hello’, ‘Welcome’);
Changing all the user’s emails
update wp_users set user_email =
replace(user_email, ‘oldemail.com’, ‘@newemail.com’);
Renaming custom post types
After you’ve changed the custom post type in functions.php from “project” to “portfolio”, file you don’t have to redo all of the data entry. All the data is still inside the MySQL database, you can just run this query.
UPDATE wp_posts SET post_type = "portfolio" WHERE post_type = "project"
The Key
update TABLE_NAME set FIELD_NAME =
replace(FIELD_NAME, 'Text to find', 'text to replace with');
Last modified: September 17, 2018
Mark Endley