WordPress SQL Queries
Useful WordPress SQL Queries
These are some useful WordPress SQL queries that you run for certain results.
What it does | sql command |
---|---|
Update the site URL & home URL | UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com') WHERE option_name = 'home' OR option_name = 'siteurl'; |
Update the GUID | UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com'); |
Update the URLs in your content | UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com'); |
Update image paths only | UPDATE wp_posts SET post_content = REPLACE (post_content, 'src="https://www.oldsiteurl.com"', 'src="https://yourcdn.newsiteurl.com"'); |
Update your posts meta information | UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com'); |
Change the default “admin” username | UPDATE wp_users SET user_login = 'Your New Username' WHERE user_login = 'Admin'; |
Change your WordPress password | UPDATE wp_users SET user_pass = MD5( 'new_password' ) WHERE user_login = 'your-username'; |
Updated 3 months ago