抓虾 鲜果
google reader QQ邮箱

网站数据无非有两个:一个是文件数据,什么源码啊,图片啊;另一个就是数据库数据,所以这里我们分别对这两种数据备份+迁移

1.网站文件的备份

虚拟主机一般都是cPanel,用它自带的File Manager很方便,在网站根目录下直接compress一个压缩包,命名比如说为backup.zip

2.vps获取网站文件

登录SSH,cd到你网站目录,用wget命令下载你的文件,最后unzip解压刚才的压缩包(比如我们的站点是A.com),则执行以下命令:

cd 你的网站目录(如/home/wwwroot/A.com)
wget http://www.A.com/backup.zip
unzip backup.zip

3.网站数据库MySQL的备份,方法有两个(选择其一)

1)phpMyAdmin备份数据到本地,这个很简单,但可能较慢。

2)SSH命令行下进行。如果可以开放SSH权限的提供商,可以tk客服让他们开放SSH权限,所以可以执行以下命令,导出数据库:

mysqldump -u用户名 -p密码 数据库名 > 你随便命名.sql

然后用mv命令,移动数据库文件到网站目录(为下一步再wget做准备)

mv 刚才你命名的.sql /home/你的host用户名/public_html/A.com/

4.备份数据库到VPS(对应第三步的两个)

1)phpMyAdmin创建用户、数据库并导入数据库

大家务必把数据库名和用户名弄成和原来一样的,这样就不用改数据库连接文件,如wp-config.php了

2)还是phpMyAdmin下创建用户和数据库吧(简单些)然后在SSH下,wget远程下载刚才的数据库文件,再用MySQL命令导入~命令如下:

wget http://www.A.com/刚才你命名的.sql
mysql -u你新建的用户名 -p用户名密码 你刚才新建的数据库名 < 刚才你命名的.sql

5.一点点清理工作,把刚才的压缩包和数据库文件现在都可以删了省得一不小心被别人下载了

6.最后就是改一下DNS的A记录,看看你的成果了

你可能感兴趣的文章

10 Responses to “网站数据从虚拟主机迁移至VPS的思路”

  1. 找传世 说道:

    说的相当的不错的哟

    [回复]

  2. Cornelius Pasley 说道:

    Beautiful photos of a fabulous couple on a fantastic day

    [回复]

  3. hula necklaces 说道:

    Some really prime content on this site, bookmarked .

    [回复]

  4. I went over this web site and I think you have a lot of great information, saved to favorites (:.

    [回复]

  5. plumbingfixtures 说道:

    I precisely wanted to thank you very much all over again. I do not know what I would’ve handled without the type of points shown by you on that topic. It became a very depressing condition in my view, but taking a look at the very skilled mode you handled it forced me to jump for fulfillment. I am just grateful for your help and have high hopes you find out what a powerful job you are carrying out educating people today thru your web blog. I am sure you have never come across any of us.

    [回复]

  6. Many thanks for this article. I would also like to state that it can often be hard when you are in school and simply starting out to establish a long credit history. There are many individuals who are simply just trying to endure and have a lengthy or beneficial credit history can often be a difficult element to have.

    [回复]

  7. Wow! This can be one of the most useful blogs we have ever come across on thesubject. Basically wonderful article! I’m also a specialist in this topic therefore I can understand your hard work.

    [回复]

  8. Hotels in Benidorm 说道:

    Do you mind if I quote a few of your articles as long as I provide credit and sources back to your webpage? My website is in the very same niche as yours and my visitors would certainly benefit from some of the information you present here. Please let me know if this okay with you. Thank you!

    [回复]

  9. 动漫原创制作 说道:

    说的很不错哟,收藏下

    [回复]

Leave a Reply