1. 修改Wordprss数据库
1.1. 启动非安全模式
21:05:41 UPDATE ${your_database}.wp_comments SET comment_content = replace(comment_content , 'oldsite_url', 'newsite_url') Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect. 0.000 sec
1.2. 执行替换命令
USE ${your_database};
SELECT FROM wp_options;
UPDATE wp_options SET option_value = 'http://newsite_url' WHERE option_name = 'siteurl';
UPDATE wp_options SET option_value = 'http://newsite_url' WHERE option_name ='home';
UPDATE wp_options SET option_value = REPLACE(option_value,'oldsite_url','newsite_url');
SELECT FROM wp_options;
SELECT FROM wp_posts;
UPDATE wp_posts SET guid= replace(guid, 'oldsite_url','newsite_url');
UPDATE wp_posts SET post_content = replace(post_content,'oldsite_url','newsite_url');
UPDATE wp_posts SET post_excerpt= replace(post_excerpt,'oldsite_url','newsite_url');
SELECT FROM wp_posts;
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'oldsite_url', 'newsite_url');
UPDATE wp_comments SET comment_content = replace(comment_content , 'oldsite_url', 'newsite_url');
SELECT FROM wp_postmeta;
SELECT FROM wp_comments;
2.网站启动失败报错
可能是因为切换部署环境后,原有插件对新版本的php相关内容不兼容导致, 可以登录 后台数据库查看 表wp_options, 然后查看 active_plugins该行修改。
例如原有的5个插件 a:5:{i:0;s:21:"backwpup/backwpup.php";i:1;s:35:"popularis-extra/popularis-extra.php";i:2;s:43:"themeisle-companion/themeisle-companion.php";i:3;s:27:"woocommerce/woocommerce.php";i:4;s:24:"wpforms-lite/wpforms.php";}
更换为0插件
a:0:{}
Use phpMyAdmin to deactivate all plugins.
In the table wp_options, under the option_name column (field) find the active_plugins row
Change the option_value field to: a:0:{}