sql 替换 WordPress 数据库
我正在将我的 WordPress 安装转移到新服务器和新域。我已移动所有文件,并创建了一个新数据库并更改了 wp-config.php
中的设置以反映这一点。然而,在导入所有内容后,它仍然指向我以前的域。我希望切断与以前的域的所有联系,因此我想执行 SQL 查询(通过 phpMyAdmin
)来替换旧域的每个实例并将它们更改为我的新域。
我偶然发现了以下内容:
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://oldlink.com', 'http://newlink.com');
我尝试用 *
替换 wp_table
实例,但它会引发语法错误。你们中的任何聪明人都可以帮我改变这个查询吗?谢谢!
I'm in the process of moving my wordpress installation over to a new server and a new domain. I have all the files moved over and I have a new database created and changed the settings in wp-config.php
to reflect this. However, upon importing everything, it's still pointing to my previous domain. I'm looking to cut ALL ties to my previous domain, so I want to do an SQL query (through phpMyAdmin
) to replace EVERY instance of my old domain and change them to my new domain.
I've stumbled upon the following:
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://oldlink.com', 'http://newlink.com');
I've tried replacing the wp_table
instances with *
and it throws a syntax error. Can any of you fine intelligent people help me out with altering this query? thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过 SQL 更新它会非常痛苦,因为您有大约 13 个表(如果您有插件,则更多),每个表都有很多列。
我有两种方法可以做到这一点
如果您有创建自己的选项卡的插件:
上进行查找和替换
将整个数据库导出到 SQL 文件中,在文本编辑器中打开并在以下oldomain.com /path/to/wordpressinstall
newdomain.com/path/to/install
您可能只需要 olddomain.com 和 newdomain.com,而不需要任何子文件夹。 超级重要的是,不要在末尾包含任何内容,例如 http:// 或 www 以及任何尾随斜杠。这将匹配 100% 的网址,无论它们是否如下所示:
http://domain.com /wp-content/lol.jpg
www.domain.com
www.domain.com/
完成后,删除旧数据库并导入此数据库。
如果它只是一个简单的 WordPress 安装
在您的 wp-config 文件中设置 url:
现在您已经对站点 url 进行了硬编码,您可以登录到新站点,下载一个名为搜索和替换的插件并运行上面的搜索/替换有漂亮的 GUI 界面。
Updating it via SQL will be way too much of a pain because ou have ~13 tables (more if you have plugins) each with many columns.
I have two ways of doing this
If you have plugins that created their own tabes:
Export the entiredatabase into a SQL File, open up in a text edior and do a find and replace on the following
oldomain.com/path/to/wordpressinstall
newdomain.com/path/to/install
Chances are you will just need olddomain.com and new domain.com without any sub folders. Its super important that you do not include anything such as http:// or www as well as any trailing slashes at the end. This will match 100% of the urls regardless of if they look like this:
http://domain.com/wp-content/lol.jpg
www.domain.com
www.domain.com/
Once you are done, delete your old DB and import this one.
If its just a simple wordpress install
Set the urls in your wp-config file:
Now that you have hard coded the site url you can log into your new site, download a plugin called search and replace and run the above search/replace with the nice GUI interface.