Edit wp_options via shell

mysql> SELECT * FROM wp_options WHERE option_name = 'home';
+-----------+-------------+------------------------+----------+
| option_id | option_name | option_value           | autoload |
+-----------+-------------+------------------------+----------+
|         2 | home        | https://www.asp.co.in | yes      |
+-----------+-------------+------------------------+----------+
1 row in set (0.00 sec)

mysql> UPDATE wp_options SET option_value="https://asp.co.in/" WHERE option_name = "home";
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> SELECT * FROM wp_options WHERE option_name = 'home';
+-----------+-------------+--------------------------+----------+
| option_id | option_name | option_value             | autoload |
+-----------+-------------+--------------------------+----------+
|         2 | home        | https://asp.co.in/ | yes      |
+-----------+-------------+--------------------------+----------+
1 row in set (0.00 sec)

mysql> SELECT * FROM wp_options WHERE option_name = 'siteurl';
+-----------+-------------+--------------------------+----------+
| option_id | option_name | option_value             | autoload |
+-----------+-------------+--------------------------+----------+
|         1 | siteurl     | https://asp.co.in/ | yes      |
+-----------+-------------+--------------------------+----------+
1 row in set (0.00 sec)

Best to do options, posts, post content and post meta:

UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');

UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');

Related posts

Latest posts

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *