简体   繁体   English

如何在服务器上的phpmyadmin上传大型sql文件

[英]how to upload a large sql file in phpmyadmin on server

How can i upload a large sql file in phpmyadmin on server. 我如何在服务器上的phpmyadmin上传一个大的sql文件。 I'm trying to migrate my wordpress website from localhost to online but when i'm trying to upload my sql file which is large then 50 MB it show error. 我正在尝试将我的wordpress网站从localhost迁移到在线,但是当我试图上传我的sql文件时,它大50 MB它显示错误。 I have only cpanel access. 我只有cpanel访问权限。

modify two limit options in 'php.ini' 修改'php.ini'中的两个限制选项

// larger than 50M
upload_max_filesize = 00M
post_max_size = 00M

You can upload large .sql file in two way. 您可以通过两种方式上传大型.sql文件。

1.Edit the php.ini page 1.编辑php.ini页面

post_max_size = 800M 
upload_max_filesize = 800M 
max_execution_time = 5000 
max_input_time = 5000 
memory_limit = 1000M 

most of the case the execution time will be time out and fail the upload. 大多数情况下,执行时间将超时并且无法上传。

  1. so that use the command line if you have back end access. 如果您有后端访问权限,请使用命令行。

    mysql -p -u your_username your_database_name < file.sql mysql -p -u your_username your_database_name <file.sql

    mysql -p -u example example_live < /home2/example/public_html/file.sql mysql -p -u example example_live </home2/example/public_html/file.sql

/home2/example/public_html/file.sql (file path) /home2/example/public_html/file.sql(文件路径)

Given the limitations your host places on your account, I think your best solution is to use the phpMyAdmin " UploadDir " feature. 鉴于您的主机对您帐户的限制,我认为您最好的解决方案是使用phpMyAdmin“ UploadDir ”功能。

You'll need to be able to control the configuration of your phpMyAdmin, which probably means you'll need to install your own copy to your web space, but that's relatively easy . 您需要能够控制phpMyAdmin的配置,这可能意味着您需要将自己的副本安装到您​​的Web空间,但这相对容易 Then you'll have to modify your config.inc.php to add a line like $cfg['UploadDir'] = 'upload'; 然后你必须修改你的config.inc.php来添加一行像$cfg['UploadDir'] = 'upload'; (you can use any directory name here). (您可以在此处使用任何目录名称)。 Next, create the directory and upload your SQL file there using SFTP, SSH, or whatever other means your host gives you of interacting with your files. 接下来,创建目录并使用SFTP,SSH或主机为您提供与文件交互的其他方式上传SQL文件。 Now the file should appear in a dropdown on the Import tab. 现在该文件应出现在“导入”选项卡的下拉列表中。

You need to break your SQL file into smaller SQL files. 您需要将SQL文件分解为较小的SQL文件。

To do this when you export from localhost, only choose a few tables to export at a time (you may have to choose the Custom export method). 要从localhost导出时执行此操作,请一次只选择要导出的几个表(可能必须选择自定义导出方法)。

Basically you need to make every SQL file smaller than 50MB. 基本上你需要使每个SQL文件小于50MB。 You can then import each SQL file, one by one. 然后,您可以逐个导入每个SQL文件。

You can compress your sql file, then upload the sql zip file to the server. 您可以压缩您的sql文件,然后将sql zip文件上传到服务器。 If the file size is still higher than limit stated in your server, you may need to increase the limits as explained by @DongHyun. 如果文件大小仍然高于服务器中规定的限制,则可能需要按照@DongHyun的说明增加限制。

However, most shared hosting plans don't allow PHP.ini editing. 但是,大多数共享主机方案都不允许进行PHP.ini编辑。 In that case, contacting customer support might be helpful. 在这种情况下,联系客户支持可能会有所帮助。

Try to import it from mysql console as per the taste of your OS. 尝试根据您的操作系统的味道从mysql控制台导入它。

mysql -u {DB-USER-NAME} -p {DB-NAME} < {db.file.sql path}

or if it's on a remote server use the -h flag to specify the host. 或者,如果它位于远程服务器上,请使用-h标志指定主机。

mysql -u {DB-USER-NAME} -h {MySQL-SERVER-HOST-NAME} -p {DB-NAME} < {db.file.sql path}

for more example 更多的例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM