Skip to content

Instantly share code, notes, and snippets.

@maravedi
Last active August 29, 2015 14:13
Show Gist options
  • Save maravedi/a4421ffeccf975a9f579 to your computer and use it in GitHub Desktop.
Save maravedi/a4421ffeccf975a9f579 to your computer and use it in GitHub Desktop.
Changing Wordpress Siteurl through MySQL CLI

I retrieved this information from Wordpress.org and StackOverflow.

So, if you're like me, you started out with a Wordpress.com version of your blog. Then you moved to your own hosted WordPress installation. Now, you are ready to start messing with themes. So you have probably copied your WordPress files and your database over to your local machine. Now you're trying to log into the wp-admin page but you're being redirected to your live WordPress installation rather than your local one. You just need to change the siteurl in the local WordPress database. Here's what you do:

#####1. Login to your local MySQL.

mysql -u username -p

#####2. Use the WordPress Database.

use wordpress;

#####3. Check the current value of siteurl.

select * from wp_options where option_name = 'siteurl';

You should see something like this:

+-----------+-------------+---------------------+----------+
| option_id | option_name | option_value        | autoload |
+-----------+-------------+---------------------+----------+
|         1 | siteurl     | http://yourblog.com | yes      |
+-----------+-------------+---------------------+----------+

#####4. Update the value of siteurl.

update wp_options SET option_value = 'http://localhost:8000' WHERE option_name = 'siteurl';

Now if you check the new value of siteurl, you should see something like this:

+-----------+-------------+-----------------------+----------+
| option_id | option_name | option_value          | autoload |
+-----------+-------------+-----------------------+----------+
|         1 | siteurl     | http://localhost:8000 | yes      |
+-----------+-------------+-----------------------+----------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment