简体   繁体   English

为什么Mysql命令行导入比PhpMyAdmin慢

[英]Why Mysql command line import slower than PhpMyAdmin

I've a mysql dump file, it's size 3.6 MB . 我有一个mysql转储文件,它的大小为3.6 MB。 First i've tried import it to my remote server with this terminal command 首先,我尝试使用此终端命令将其导入我的远程服务器

mysql -hHOST -uUSER -p DBNAME < /path/of/backup.sql

It took about 30 minutes (really) . 花了大约30分钟(真的)。

And then i've tried importing same file via PhpMyAdmin on my remote server, and it took about 1.5 MINUTES . 然后我尝试通过PhpMyAdmin在我的远程服务器上导入相同的文件,大约需要1.5分钟 Can you tell me why mysql command is really so slow than PhpMyAdmin. 你能告诉我为什么mysql命令真的比PhpMyAdmin慢得多。 They both uplaoding 3.6 MB file and then executing same amount of SQL queries. 它们都会上传3.6 MB文件然后执行相同数量的SQL查询。

这是网络相关的问题,只需在mysql服务器上移动文件,然后在本地导入,它应该只需要10到15秒:

mysql -uroot -p dbname < /root/backup.sql

The local mysql cli client does not transfer a file of 3.6MB. 本地mysql cli客户端不传输3.6MB的文件。 Instead it transfers every single query inside the file separately. 相反,它会单独传输文件中的每个查询。 This leads to a much higher network latency, depending on network connection and server setup. 这会导致更高的网络延迟,具体取决于网络连接和服务器设置。 It's the difference between streaming a single block of binary data and thousands of blocks adding up to the same volume. 流式传输单个二进制数据块和数千个块加起来相同的音量之间的区别。

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

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