« cPanel中如何绑定多个域名到同一个网站 | Main | 国外空间介绍导航 »

用cPanel向虚拟主机导入大型数据库

【原创】再也不用为上传数据库苦恼 - 用cPanel向虚拟主机导入大型数据库

大家都知道phpMyAdmin导入数据库有尺寸的限制,而且时间稍长就会time out导入失败。

网上也有各种软件用来导入,通常采用切割sql文件为多个小包的方法实现,繁琐而成功率也不是很高的。

如果你的数据库较大,你就会常常烦恼。。。


我一直用SSH直接登录到虚拟主机上直接运行如下命令来导入的:

mysql -u 用户名 -p口令 [-h 数据库主机]  数据库  < 数据库备份.sql

不过很多空间提供商都不给开放SSH或telnet权限。


突然想到可以用crontab来运行命令呀。测试一下成功了。


1. 通过ftp上传你的备份sql文件,放在根目录下就可以了。

2. 进入你的cPanel, 看到cron jobs 这个图标,点击进去,然后选Advanced (Unix Style) (呵呵我比较习惯unix哈)。

因为只需要运行一次,所以Minute, Hour, Day, Month 都填入准备运行的具体时间,留两分钟余量就行(如果虚拟主机不在本地,可以在FTP上查看一下主机时间), Weekday填*号算了。

Command 填待运行的命令,就是导入命令:

mysql -u 用户名 -p口令 [-h 数据库主机]  数据库  < 数据库备份.sql

3.在phpMyAdmin里监视导入情况。

速度很快,我1G的数据库也就几分钟吧。

TrackBack

TrackBack URL for this entry:
http://www.hostgator-bluehost.com/cgi-bin/mt-tb.cgi/47

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on January 20, 2007 11:36 PM.

The previous post in this blog was cPanel中如何绑定多个域名到同一个网站.

The next post in this blog is 国外空间介绍导航.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33
Hosted by IXWebHosting.com