简体   繁体   English

无法将太大的sql文件导入mysql

[英]cannot import too large sql file to mysql

I have a 28 MB sql file need to import to mysql. 我有一个28 MB的sql文件需要导入到mysql。 Firstly, i'm using xampp to import, and it fails, and so i change my max_file_uploads, post_size(something like that)in php.ini-development and php.ini-product to 40 MB, but it still show "max:2048kb" and import fail again. 首先,我使用xampp导入,但失败,因此我将php.ini-development和php.ini-product中的max_file_uploads,post_size(类似)更改为40 MB,但它仍然显示“ max: 2048kb”,导入再次失败。

From research, i've learned to import by using mysql.exe, so i open mysql.exe and type the command line(msdos) below: 从研究中,我已经学会了使用mysql.exe进行导入,因此我打开mysql.exe并在下面键入命令行(msdos):

-u root -p dbname < C:\xxx\xxx\sqlfile.sql

but still failed again and again..... 但仍然失败一次又一次.....

what the problem is? 问题是什么? xampp? xampp? or my sql setting? 还是我的SQL设置?

Try this: 尝试这个:

mysql -uroot -p --max_allowed_packet=24M dbname

Once you log into the database: 登录数据库后:

source C:\xxx\xxx\sqlfile.sql

I think that you should be able to load your file 我认为您应该能够加载文件

How large is your file?. 您的文件有多大? You might as well do it from a console: 您也可以从控制台执行此操作:

mysql -u##USER## -p ##YOUR_DATABASE## < ##PATH_TO_YOUR_FILE##

Do that without executing your mysql.ext file: just "cd" right into the directory and try the command. 无需执行mysql.ext文件即可执行此操作:只需在目录中“ cd”并尝试命令即可。

It will ask for your password and start importing right away. 它将要求您输入密码并立即开始导入。 Don't forget to create the database or delete all tables if it's already there. 如果数据库已经存在,请不要忘记创建数据库或删除所有表。

I always found this approach quick, painless and easier that rolling around with php directives, phpmyadmin configuration or external applications. 我总是发现这种方法与php指令,phpmyadmin配置或外部应用程序一起使用时快速,轻松且容易。 It's right there, built into the mysql core. 就在这里,内置在mysql核心中。

You should increase max_allowed_packet in MySQL. 您应该在MySQL中增加max_allowed_pa​​cket。

Just execute this command before importing your file: 只需在导入文件之前执行以下命令:

set global max_allowed_packet=1000000000;

I also fetched the similar problem. 我也提出了类似的问题。 So after that I also conclude , large sql file will never be imported to mysql. 因此,在此之后,我也得出结论, 大型sql文件将永远不会导入到mysql中。 It will always give timeout error. 它总是会给出超时错误。

Then I found a solution. 然后我找到了解决方案。

There is an software Heidisql . 有一个软件Heidisql

follow below steps:- 请按照以下步骤操作:-

1) download the software.
2) then install the software
3) create new session in Heidisql and open the session
4) then go to Tools -> Load SQL File -> Browse. 

That's it. 而已。 This solution works best for me. 此解决方案最适合我。

check the link here 这里检查链接

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

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