WordPress SQL Queries

Useful WordPress SQL Queries

These are some useful WordPress SQL queries that you run for certain results.

What it doessql command
Update the site URL & home URLUPDATE 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 GUIDUPDATE wp_posts SET guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
Update the URLs in your contentUPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
Update image paths onlyUPDATE wp_posts SET post_content = REPLACE (post_content, 'src="https://www.oldsiteurl.com"', 'src="https://yourcdn.newsiteurl.com"');
Update your posts meta informationUPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
Change the default “admin” usernameUPDATE wp_users SET user_login = 'Your New Username' WHERE user_login = 'Admin';
Change your WordPress passwordUPDATE wp_users SET user_pass = MD5( 'new_password' ) WHERE user_login = 'your-username';