将数据库一个域移动到其他域 [英] Moving Database one domain to other
问题描述
我试图将WordPress网站移至其他网域。
例如: http://www.demo.com 到 http://www.localhost/demo ....
和我已经从c面板的xml文件备份。所有的表都有。并在编辑器中更改了网址。
I was trying to move WordPress website to another domain. Ex: http://www.demo.com to http://www.localhost/demo.... and i have taken xml file backup from c-panel.All the tables are there.And changed url in editor.
当我将xml文件导入wordpress信息中心时,页面/帖子没有上传。只有默认页面和帖子都有
同样的问题。
When i imported xml file into wordpress dashboard, Pages/posts are not uploading. Only default page and post are there Same problem.
任何人都可以指导我在做什么错误和解决方案?
Can Anybody guide me what mistake i am doing and what is the solution ??
感谢进阶
推荐答案
这里是我每当我移动网站不同的域(或从本地主机到网络上的某个位置):
Here's what I do whenever I have to move a site to a different domain(or from localhost to somewhere on the web):
- 复制文件 - 如果您能够zip / unzip一个文件在旧的和新的服务器,只是使所有的WordPress文件(
/ wp-admin
,/ wp -content
,/ wp-includes
和所有文件,否则将它们复制到您的计算机 - 数据库复制
- 在新服务器上,上传
- 在新服务器上导入数据库备份。
- 一旦您完成了.zip文件上传数据库,执行以下SQL代码(您可以从phpMyAdmin实例)
- Make a copy of your files - if you'll be able to zip/unzip a file on both the old and new server, just make a .zip archive with all WordPress files(
/wp-admin
,/wp-content
,/wp-includes
and all files in the root directory, otherwise copy them to your computer - Make a Database Copy
- On the new server, upload your files(if you did a .zip archive, upload it and unpack it)
- Import the database backup on the new server.
- Once you've uploaded the database, execute the following SQL code(you can do that from phpMyAdmin for instance)
:
UPDATE `{%TABLE_PREFIX%}options` SET `option_value` = replace(`option_value`, '{OLD_URL}', '{NEW_URL}');
UPDATE `{%TABLE_PREFIX%}postmeta` SET `meta_value` = replace(`meta_value`, '{OLD_URL}', '{NEW_URL}');
UPDATE `{%TABLE_PREFIX%}posts` SET `post_content` = replace(`post_content`, '{OLD_URL}', '{NEW_URL}');
UPDATE `{%TABLE_PREFIX%}posts` SET `guid` = replace(`guid`, '{OLD_URL}', '{NEW_URL}');
取代 {%...%}
具有相应值的占位符如下:
Replace the {%...%}
placeholders with the corresponding values as follows:
{%TABLE_PREFIX%}
wp-config.php
{OLD_URL}
网站所在的旧网址。我通常跳过 http://
部分和尾部斜杠(一些路径保存,一些没有它,所以这样做更安全),所以如果你的网站以前在 http://www.demo.com/
上,您可以用 {OLD_URL}
替换 www.demo.com
{OLD_URL}
is the old URL where the site resided. I usually skip the http://
part and the trailing slash(some paths are saved with, some without it, so it's safer to do it that way), so if your site used to be on http://www.demo.com/
, you would replace {OLD_URL}
with www.demo.com
{NEW_URL}
站点将驻留的新URL。我通常跳过 http://
部分和尾部斜杠,所以如果你的网站将驻留在 http://www.localhost / code>,您将用
www.localhost
替换 {NEW_URL}
。如果新位置是子目录(例如 http://www.localhost/example/
),您将替换 {NEW_URL}
与 www.localhost / example
。
{NEW_URL}
is the new URL where the site will reside. I usually skip the http://
part and the trailing slash, so if your site will reside on http://www.localhost/
, you would replace {NEW_URL}
with www.localhost
. If the new location is a sub-directory(for instance http://www.localhost/example/
), you will replace {NEW_URL}
with www.localhost/example
.
完成所有这些操作后,只需转到新安装,登录到仪表板,转到设置>
Once you're done with all of that, just go to your new installation, log-in to the dashboard, go to Settings > Permalinks
and unless you see a .htaccess permissions error, you're all set :)
如果您无法通过phpMyAdmin访问数据库,您将看到一个.htaccess权限错误, ,或者您无法备份文件,请考虑使用返回-up plugin
If you can't access the DB via phpMyAdmin, or you can't make a back-up of your files, consider using a back-up plugin
这篇关于将数据库一个域移动到其他域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!