phpMyAdmin:无法导入巨大的数据库文件,有什么建议吗?

发布于 2024-10-18 10:50:42 字数 662 浏览 3 评论 0 原文

我最近买了一台新电脑,所以我想把我所有的网络项目都搬过来。移动文件很容易,但是移动数据库似乎有点困难。我使用 phpMyAdmin 导出所有数据库,并将其保存到 localhost.sql。然后我尝试使用 phpMyAdmin 将其导入到我的新计算机上,但出现错误:

No data to import. Either no filename was sent or the filesize exceeded the maximum allowed size. See FAQ 1.16. (This was translated from Swedish)

我按照建议查看了常见问题解答。他们提到了一个名为 BigDump 的工具。所以我下载了它,在查看了运行它所需的设置后,我意识到我也不能使用它。为什么?因为它需要连接到一个特定的数据库。我正在尝试一次导入许多数据库。所以,那里没有成功。

我还尝试将 PHP 的 upload_max_filesize (以及常见问题解答中提到的另一个)设置为 999 之类的值。由于某种原因,这似乎不起作用。在再次运行之前,我确实重新启动了所有服务。

我应该提到,我在旧计算机上使用 XAMPP,并在新计算机上切换到 WAMP。但这应该不重要,对吧?因为这两个“包”都使用 phpMyAdmin 和 apache。

关于如何绕过这个噩梦有什么建议吗?

I recently got a new computer, so I thought I'd move all my web projects over. Moving the files was easy, however, moving the database seems to be a bit harder. I exported ALL databases using phpMyAdmin, and saved it to localhost.sql. Then I tried to import it on my new computer also using phpMyAdmin, and I get the error:

No data to import. Either no filename was sent or the filesize exceeded the maximum allowed size. See FAQ 1.16. (This was translated from Swedish)

I took a look at the FAQ, as advised. And they mentioned a tool called BigDump. So I downloaded it, and after looking at the settings you need to run it I realised that I CAN'T USE THAT EITHER. Why? Because it requires a connection to one specific database. I'm trying to import MANY databases at once. So, no success there.

I also tried setting PHP's upload_max_filesize (and the other one's mentioned in the FAQ) to something like 999. That doesn't seem to work either for some reason. I did restart all services before I ran it again.

I should mention that I used XAMPP on my old computer, and I switched to WAMP on my new one. That shouldn't matter though, right? As both "packages" uses phpMyAdmin and apache.

Any suggestions on how to bypass this nightmare?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(17

薄荷梦 2024-10-25 10:50:42

操作方法

确保您在 "php.ini"(位于 "php.ini 所在位置)中同时更改 *"post_max_size"* 和 *"upload_max_filesize"*。 exe” 是)。

以下示例允许您上传和导入 128MB sql 文件:

post_max_size=128M
upload_max_filesize=128M

重新启动 Apache,一切就绪。

替代方法

解决该问题的另一种方法是使用命令行。但这只是一种解决方法,并且与解决方法一样丑陋:

C:\xampp\mysql\mysql.exe -u root -p db_name < C:\some_path\your_sql_file.sql

由于您不使用服务器而是命令行,因此上传和 POST 大小并不重要。这就是为什么我称其为“解决方法”,因为它实际上并不能解决您的问题。

HowTo

Make sure you change both *"post_max_size"* and *"upload_max_filesize"* in your "php.ini" (which is located where your "php.exe" is).

The following example allows you to upload and import 128MB sql files:

post_max_size=128M
upload_max_filesize=128M

Restart Apache and you're all set.

Alternatives

An alternative way to work around the problem is to use the command line. But it's a workaround, and as ugly as workarounds get:

C:\xampp\mysql\mysql.exe -u root -p db_name < C:\some_path\your_sql_file.sql

As you're not using the server but the command line, upload and POST sizes don't matter. That's why I call this a "workaround", since it doesn't actually solve your problem.

悍妇囚夫 2024-10-25 10:50:42

其他人总是尝试重新配置 php.ini 文件,但对我来说,我认为最佳实践是使用 MYSQL 控制台,因为它确实节省了您的时间。

以下是 MYSQL 控制台的分步指南:

打开 MYSQL 控制台,然后运行它。

类型:

mysql>使用database_name;

mysql> source location_of_your_file;

location_of_your_file 应该类似于 C:\mydb.sql

所以命令是 mysql>source C:\mydb.sql;

这种导入 sql 转储对于 BIG SQL 非常有帮助文件。

我将文件 mydb.sql 复制到目录 C: 。它应该是大写 C: 才能运行,因为它会给你一个 mysql 错误或语法错误

Others are always trying to reconfigure the php.ini file but for me I think the best practice is use your MYSQL console because it really saves your time.

Here are the step by step guide to the MYSQL Console:

Open your MYSQL Console then run it.

Type:

mysql> use database_name;

mysql> source location_of_your_file;

location_of_your_file should look like C:\mydb.sql

so the command is mysql>source C:\mydb.sql;

This kind of importing sql dump is very helpful for BIG SQL FILE.

I copied my file mydb.sql to directory C: .It should be capital C: in order to run because it will give you a mysql error or syntax error

假面具 2024-10-25 10:50:42

在 wamp 服务器中:

  1. 打开路径“C:\wamp\apps\phpmyadmin”中的 config.inc.php 文件并设置/添加此行。 $cfg['UploadDir'] = 'upload';
  2. 重新启动所有服务
  3. 现在在 phpmyadmin(C:\wamp\apps\phpmyadmin4.0.4\upload) 文件夹中创建 upload 文件夹,并将 .sql 文件放入upload 文件夹。
  4. 现在在浏览器中打开 phpmyadmin,进入导入。您可以在浏览按钮下方的下拉列表中看到该文件以及上传目录文件夹和文件。
  5. 选择它并转到...

in wamp server:

  1. Open config.inc.php file in the path "C:\wamp\apps\phpmyadmin" and set/add this line. $cfg['UploadDir'] = ‘upload’;
  2. Restart all services
  3. Now create upload folder inside your phpmyadmin(C:\wamp\apps\phpmyadmin4.0.4\upload) folder and put your .sql file in upload folder.
  4. Now open phpmyadmin in browser, go to import. You can see the file in dropdown just below browse button with that upload directory folder and files.
  5. Select it and Go…
∞觅青森が 2024-10-25 10:50:42

xampp\php\php.ini中进行更改

查找:

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

更改为:

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

Make changes in xampp\php\php.ini

Find:

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

Change to:

post_max_size       = 750M
upload_max_filesize = 750M
max_execution_time  = 5000
max_input_time      = 5000
memory_limit        = 1000M
横笛休吹塞上声 2024-10-25 10:50:42

您可以从命令行导入 - 类似 mysql < databasedump.sql(取决于操作系统)。

You can import from the command line - something like mysql < databasedump.sql (depending on the OS).

凉栀 2024-10-25 10:50:42

按照以下步骤转储大型数据库:

1) 从 BigDump.php ="nofollow">http://www.ozerov.de/bigdump/

2) 将您的 bigdump.phpdatabasedump.sql 移动到项目文件夹中(htdocs 或 www)。

3) 打开 bigdump.php 文件并编辑以下部分:

$db_server   = 'localhost';
$db_name     = '';
$db_username = '';
$db_password = ''; 

$filename           = '.sql';  

4) 在浏览器中打开 bigdump.php 并单击导入链接。

Follow this step to dump huge database:

1) Download php script BigDump.php from http://www.ozerov.de/bigdump/

2) Move your bigdump.php and your databasedump.sql in projects folder (htdocs or www).

3) open bigdump.php file and edit bellow section:

$db_server   = 'localhost';
$db_name     = '';
$db_username = '';
$db_password = ''; 

$filename           = '.sql';  

4) open bigdump.php in browser and click on import link.

心碎无痕… 2024-10-25 10:50:42

这将在几秒钟内导入您的大型 sql 文件:

e:\xampp\mysql\bin>mysql -u root -h localhost < verybigsqlfile.sql

不要使用 phpmyadmin 导入大型 sql 文件。如果你在线使用mysql,那么采取mysql控制台访问。

This will import your large sql file within few seconds:

e:\xampp\mysql\bin>mysql -u root -h localhost < verybigsqlfile.sql

Don't use phpmyadmin to import large sql files. If you are using mysql online, then take the mysql console access.

野生奥特曼 2024-10-25 10:50:42

压缩 sql 文件(仅限 gzip、bzip2、zip)并导入。压缩 db csv 文件等测试文件将显着减小文件大小(约 11 mb 至 2 mb),并且 phpmyadmin 导入引擎可以检测压缩数据

compress sql file (only gzip, bzip2, zip) and import it. compressing test files like db csv file will reduce file size dramatically (~ 11 mb to 2 mb) and phpmyadmin import engine cand etect compressed data

拥抱我好吗 2024-10-25 10:50:42

我知道这很旧但是..
我很久以前就想到了这个问题。
我要么使用控制台来执行转储sql 文件。
或者我使用 adminer 作为 PHPmyAdmin 的替代品。

I know this is old but..
I came up with this problem long ago.
Either I used the console to execute dump sql file.
Or I use adminer as an alternative to PHPmyAdmin.

茶底世界 2024-10-25 10:50:42

修改my.ini文件

中的[mysqld]部分添加以下行

wait_timeout=28800
interactive_timeout = 28800
max_allowed_packet=32M

重新启动mysql

打开dump.sql文件
添加以下

use mydbname

行转到 mysql 文件夹并运行此命令

mysql -u root -h localhost < dump.sql

Modify the my.ini file

in the [mysqld] section add the following lines

wait_timeout=28800
interactive_timeout = 28800
max_allowed_packet=32M

Restart the mysql

open the dump.sql file
add the following lines

use mydbname

Go to the mysql folder and run this command

mysql -u root -h localhost < dump.sql
淡淡離愁欲言轉身 2024-10-25 10:50:42

phpmyadmin 还能够从硬盘读取数据 - 上传转储并使用此功能。但是,如果可能的话,我强烈建议您从控制台进行。它的速度要快得多,因为 php 不必先处理文件,它会直接加载到服务器中。

phpmyadmin has the ability to read from the harddrive as well - upload the dump and use this feature. However, I would strongly advise you to the from the console if possible. It's way faster as php doesn't have to process the file first and it gets loaded directly into the server.

秋风の叶未落 2024-10-25 10:50:42

如果您上传的数据库非常大,但 Web 界面将限制为 HTTP 最大 HTTP 请求大小

编辑 PHP.ini 以增加上传限制

找到此行

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =

; Maximum allowed size for uploaded files.
upload_max_filesize = ??M **<--- change here ....**

然后重启服务器

/sbin/service httpd restart

或者使用directadmin重启http服务

If you are having a very large database uploading though the web interface will be limited to HTTP maximum HTTP request size

Edit the PHP.ini to increase the upload limit

find this line

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =

; Maximum allowed size for uploaded files.
upload_max_filesize = ??M **<--- change here ....**

Then restart the server

/sbin/service httpd restart

or use directadmin to restart the http service

数理化全能战士 2024-10-25 10:50:42

使用SQLYog进行数据库操作是专业人士的最佳选择。通过使用 SQLYog,您可以导入 nGB {n->finite_size} 的 sql 数据库。

Use SQLYog for db operations it is the best choice for professional. By using SQLYog you can import nGB {n->finite_size} of sql db.

我一向站在原地 2024-10-25 10:50:42

我尝试更改允许的大小,但这并没有解决问题。

但是,在我的特定情况下,有一个名为“uploaddir”的文件夹,位于:

EasyPHP\modules\phpmyadmin\uploaddir

我将 SQL 文件放在那里,然后返回到 PHP My Admin 的“导入”选项卡。
有一个选项允许我上传已位于“uploaddir”文件夹中的文件;他们没有限制。

我正在使用 Windows 和 EasyPHP 12.1

I tried to change the allowed size, but that didn't fixed the problem.

However, there's a folder called "uploaddir", in my particular case, located in:

EasyPHP\modules\phpmyadmin\uploaddir

I put the SQL file there, and then went back to the "Import" tab of PHP My Admin.
There's an option that allowed me to upload files that were already located in "uploaddir" folder; and they have no limit.

I'm using Windows and EasyPHP 12.1

羅雙樹 2024-10-25 10:50:42

简单的解决方案是只需下载并安装安装“MySql Workbench”软件,它基于图形用户界面且易于使用。我最近导入了300mb大小的mysql数据库。

Simple solution is that just download & install "MySql Workbench" software, its gui based and easy to use.I have recently import 300mb size mysql database.

高冷爸爸 2024-10-25 10:50:42

如果您使用的是 Linux,您可以转到终端,在连接到 mysql 并选择数据库后,只需键入:

\. /path/to/database/database.sql

If you'r on linux, you can go to terminal and after connect to mysql and select database, simply type:

\. /path/to/database/database.sql
小霸王臭丫头 2024-10-25 10:50:42

sql 重新提交链接

1

您可以再次重新提交 SQL 文件,直到数据库未完全上传

sql resubmit link

1

You can resubmit your SQL file again until database not fully uploaded

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文