MySQL 如何在phpmyadmin中导入大型sql文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11305516/
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
How to import large sql file in phpmyadmin
提问by Jasmeet Kaur Chauhan
I want to import a sql file of approx 12 mb. But its causing problem while loading. Is there any way to upload it without splitting the sql file ?
我想导入一个大约 12 mb 的 sql 文件。但它在加载时导致问题。有没有办法在不拆分sql文件的情况下上传它?
回答by manurajhada
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}
回答by Toskan
3 things you have to do:
你必须做的3件事:
in php.ini
of your php installation (note: depending if you want it for CLI, apache, or nginx, find the right php.ini to manipulate)
在php.ini
你的 php 安装中(注意:取决于你是否想要它用于 CLI、apache 或 nginx,找到正确的 php.ini 来操作)
post_max_size=500M
upload_max_filesize=500M
memory_limit=900M
or set other values.
或设置其他值。
Restart/reloadapache if you have apache installed or php-fpm for nginx if you use nginx.
如果您安装了 apache,请重新启动/重新加载apache,如果您使用 nginx,请为 nginx 安装 php-fpm。
Remote server?
远程服务器?
increase max_execution_time
as well, as it will take time to upload the file.
也增加max_execution_time
,因为上传文件需要时间。
NGINX installation?
NGINX 安装?
you will have to add: client_max_body_size 912M;
in /etc/nginx/nginx.conf
to the http{...}
block
你将不得不增加:client_max_body_size 912M;
在/etc/nginx/nginx.conf
该http{...}
块
回答by Siraj Khan
Edit the config.inc.php file located in the phpmyadmin directory. In my case it is located at C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php
.
编辑位于 phpmyadmin 目录中的 config.inc.php 文件。就我而言,它位于C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php
.
Find the line with $cfg['UploadDir']
on it and update it to $cfg['UploadDir'] = 'upload';
找到上面的行并将$cfg['UploadDir']
其更新为$cfg['UploadDir'] = 'upload';
Then, create a directory called ‘upload' within the phpmyadmin directory (for me, at C:\wamp\apps\phpmyadmin3.2.0.1\upload\
).
然后,在 phpmyadmin 目录中创建一个名为“upload”的目录(对我来说是 at C:\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 文件放入新upload
目录中。现在,当您进入 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,那么我相信您将能够使其适应您的环境而不会遇到太多麻烦。
Reference : http://daipratt.co.uk/importing-large-files-into-mysql-with-phpmyadmin/comment-page-4/
参考:http: //daipratt.co.uk/importing-large-files-into-mysql-with-phpmyadmin/comment-page-4/
回答by Guille Acosta
Solution for LINUX USERS (run with sudo)
LINUX 用户的解决方案(使用 sudo 运行)
Create 'upload' and 'save' directories:
创建“上传”和“保存”目录:
mkdir /etc/phpmyadmin/upload
mkdir /etc/phpmyadmin/save
chmod a+w /etc/phpmyadmin/upload
chmod a+w /etc/phpmyadmin/save
Then edit phpmyadmin's config file:
然后编辑phpmyadmin的配置文件:
gedit /etc/phpmyadmin/config.inc.php
Finally add absolute path for both 'upload' and 'save' directories:
最后为“上传”和“保存”目录添加绝对路径:
$cfg['UploadDir'] = '/etc/phpmyadmin/upload';
$cfg['SaveDir'] = '/etc/phpmyadmin/save';
Now, just drop files on /etc/phpmyadmin/upload
folder and then you'll be able to select them from phpmyadmin.
现在,只需将文件放在/etc/phpmyadmin/upload
文件夹中,然后您就可以从 phpmyadmin 中选择它们。
Hope this help.
希望这有帮助。
回答by Vikas Khunteta
Just one line and you are done (make sure mysql command is available as global or just go to mysql installation folder and enter into bin folder)
只需一行就完成了(确保 mysql 命令可作为全局使用或只需转到 mysql 安装文件夹并进入 bin 文件夹)
mysql -u database_user_name -p -D database_name < complete_file_path_with_file_name_and_extension
Here
这里
u
stands for Userp
stands for PasswordD
stands for Database
u
代表用户p
代表密码D
代表数据库
---DON'T FORGET TO ADD <
SIGN AFTER DATABASE NAME---
---不要忘记在<
数据库名称后添加签名---
Complete file path with name and extension can be like
带有名称和扩展名的完整文件路径可以像
c:\folder_name\"folder name"\sql_file.sql
c:\folder_name\"folder name"\sql_file.sql
---IF YOUR FOLDER AND FILE NAME CONTAINS SPACE THAN BIND THEM USING DOUBLE QUOTE---
---如果您的文件夹和文件名包含空格,请使用双引号将它们绑定---
Tip and Note: You can write your password after -p
but this is not recommended because it will show to others who are watching your screen at that time, if you don't write there it will ask you when you will execute command by pressing enter.
提示和注意:您可以在之后输入密码,-p
但不建议这样做,因为它会显示给当时正在观看您屏幕的其他人,如果您不写在那里,它会询问您何时按回车键执行命令。
回答by Sachin from Pune
Create a zip or tar file and upload in phpmyadmin thats it..!
创建一个 zip 或 tar 文件并在 phpmyadmin 中上传就是这样..!
回答by cosmintam
I was able to import a large .sql
file by having the following configuration in httpd.conf
file:
.sql
通过在httpd.conf
文件中进行以下配置,我能够导入一个大文件:
Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
AllowOverride AuthConfig
Require all granted
php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360
</Directory>
回答by shxfee
You will have to edit the php.ini file. change the following upload_max_filesize
post_max_size
to accommodate your file size.
您必须编辑 php.ini 文件。更改以下内容upload_max_filesize
post_max_size
以适应您的文件大小。
Trying running phpinfo()
to see their current value. If you are not at the liberty to change the php.ini file directly try ini_set()
尝试运行phpinfo()
以查看它们的当前值。如果您不能随意更改 php.ini 文件,请直接尝试 ini_set()
If that is also not an option, you might like to give bigdumpa try.
如果这也不是一种选择,您可能想尝试一下bigdump。
回答by Nikunj K.
For that you will have to edit php.ini
file, If you are using the ubuntu server this is link Upload large file in phpMyAdminmight help you.
为此,您必须编辑php.ini
文件,如果您使用的是 ubuntu 服务器,这是在 phpMyAdmin 中上传大文件的链接可能会对您有所帮助。
回答by Daniel Karatha
I dont understand why nobody mention the easiest way....just split the large file with http://www.rusiczki.net/2007/01/24/sql-dump-file-splitter/and after just execute vie mySQL admin the seperated generated files starting from the one with Structure
我不明白为什么没有人提到最简单的方法......只需使用http://www.rusiczki.net/2007/01/24/sql-dump-file-splitter/分割大文件, 然后执行 vie mySQL admin从具有结构的文件开始的分离生成文件