MySQL 如何导入mysql数据库中超过10mb的sql文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3210713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:30:52  来源:igfitidea点击:

How to import sql files which are more than 10mb in mysql database

mysql

提问by Fero

I can't import a sql file that is more than 10 MB.

我无法导入超过 10 MB 的 sql 文件。

Is there any way to import a file that's more than 10MB using MYSQL?

有没有办法使用MYSQL导入超过 10MB 的文件?

EDIT:

编辑:

I have a mysql dump file which is more than 10MB. I can't import it in my localhost. When i try, the following error occurs:

我有一个超过 10MB 的 mysql 转储文件。我无法在我的本地主机中导入它。当我尝试时,出现以下错误:

ERROR:
You probably tried to upload too large file. Please refer to documentation for ways to workaround this limit.

Thanks in advance.

提前致谢。

回答by DrColossos

You should to do it via the commandline.

您应该通过命令行来完成。

Since you wrote localhost above, I assume you have access. It also has no time limit for importing data.

由于您在上面写了 localhost,因此我假设您可以访问。它也没有导入数据的时间限制。

mysql -u username -p database < location/to/your/dump.sql

-pwill ask you for your password. If the user has no password, ignore the flag

-p会询问您的密码。如果用户没有密码,则忽略该标志



edit: @Marco Mariani: This is a possibility, but keep in mind that this limit will be used for ALLof your PHP applications on the same server. You could change it back after the import but that's rather tedious and a high upload limit isn't a good idea IMO.

编辑:@Marco Mariani:这是一种可能性,但请记住,此限制将用于同一服务器上的所有PHP 应用程序。您可以在导入后将其改回,但这很乏味,而且高上传限制 IMO 不是一个好主意。

回答by Jiar

copy and pasted below from: Upper limit for Upload Limit and Post Limit in PHPcopy and pasted below from: http://daipratt.co.uk/importing-large-files-into-mysql-with-phpmyadmin/

复制并粘贴到以下来源:PHP 中上传限制和发布限制的上限复制并粘贴到以下来源:http: //daipratt.co.uk/importing-large-files-into-mysql-with-phpmyadmin/

It's how i overcome the exact same issue.

这就是我如何克服完全相同的问题。

When trying to import large SQL files into mysql using phpmyadmin, the phpmyadmin documentation offers a few solutions, but I find the easiest method to overcome this is…

当尝试使用 phpmyadmin 将大型 SQL 文件导入 mysql 时,phpmyadmin 文档提供了一些解决方案,但我发现克服这个问题的最简单方法是……

Find the config.inc.php file located in the phpmyadmin directory. In my case it is located here: ? 1 C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php

找到位于 phpmyadmin 目录中的 config.inc.php 文件。就我而言,它位于此处:?1 C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php

Find the line with $cfg['UploadDir']on it and update it to: ? 1 $cfg['UploadDir'] = 'upload';

找到上面的行并将$cfg['UploadDir']其更新为: ? 1 $cfg['UploadDir'] = 'upload';

Create a directory called ‘upload' within the phpmyadmin directory. ? 1 C:\wamp\apps\phpmyadmin3.2.0.1\upload\

在 phpmyadmin 目录中创建一个名为“upload”的目录。? 1C:\wamp\apps\phpmyadmin3.2.0.1\upload\

Then place the large sql file that you are trying to import into the new upload directory. Now when you go onto the db import page within phpmyadmin console you will notice a drop down present that wasn't there before – it contains all of the sql files in the upload directory that you have just created. You can now select this and begin the import.

然后将您尝试导入的大型 sql 文件放入新的上传目录。现在,当您进入 phpmyadmin 控制台中的 db 导入页面时,您会注意到一个以前不存在的下拉列表 - 它包含您刚刚创建的上传目录中的所有 sql 文件。您现在可以选择它并开始导入。

If you're not using WAMP on Windows, then I'm sure you'll be able to adapt this to your environment without too much trouble.

如果您不在 Windows 上使用 WAMP,那么我相信您将能够使其适应您的环境而不会遇到太多麻烦。

回答by errakeshpd

To resolve upload issuesyou need to edit the php.ini file

要解决上传问题,您需要编辑 php.ini 文件

edit /etc/php5/apache2/php.ini

编辑/etc/php5/apache2/php.ini

change upload file size then you can upload the maximum size DB :

upload_max_filesize = 999M

to change post data limit : post_max_size = 99M

更改上传文件大小,然后您可以上传最大大小的数据库:

上传最大文件大小 = 999M

更改帖子数据限制: post_max_size = 99M

then execute the command

然后执行命令

sudo service apache2 restart

须藤服务 apache2 重启

回答by laurent

You can use SQLyog(obs: SQLYog community edition download link) to import the data in mysql. There is no 10MB limit (from php.ini using phpmyadmin)

可以使用SQLyog(obs:SQLYog社区版下载链接)导入mysql中的数据。没有 10MB 的限制(从 php.ini 使用 phpmyadmin)

回答by Inzimam Tariq IT

If you are using MySQLin Xamppthen do the steps below.
Find the following in php.inifile

如果您正在使用MySQLXampp请执行以下步骤。
php.ini文件中找到以下内容

post_max_size = 8M
upload_max_filesize = 2M
max_execution_time = 30
max_input_time = 60
memory_limit = 8M

And change their sizes according to your need. I'm using these values

并根据您的需要更改它们的大小。我正在使用这些值

post_max_size = 30M
upload_max_filesize = 30M
max_execution_time = 4500
max_input_time = 4500
memory_limit = 850M

Note:1upload_max_filesizeis essential Butit's better to change all.

注意:1upload_max_filesize是必不可少的,最好全部更改。

Note:2You must restart apache service.

注意:2您必须重新启动 apache 服务。

回答by Ziv Rozenberg

Try zipping the .sqlfile. Worked great for me.

尝试压缩.sql文件。对我很有用。

回答by Vikas Jyoty

If you are want to import a file that is more than 2 mb, try importing in zipped format. Make sure you name the zip as filename.sql.zip , in case of other compressions change the extension accordingly. I imported a 10 mb file (magento sample data), after compression it became 1.8 mb, and upload done.

如果您要导入超过 2 mb 的文件,请尝试以压缩格式导入。确保将 zip 命名为 filename.sql.zip ,以防其他压缩相应地更改扩展名。我导入了一个 10 mb 的文件(magento 示例数据),压缩后变成了 1.8 mb,上传完成。

回答by Marco Mariani

This happens because you are using php/phpmyadmin.

发生这种情况是因为您正在使用 php/phpmyadmin。

You can change the max_upload setting in php.ini (or do it from the command line)

您可以更改 php.ini 中的 max_upload 设置(或从命令行执行)