简体   繁体   中英

Error 2013 while re-importing my MySQL dump after fresh re-install my OS

I've ran into a problem with my computer, so I needed to format it and fully re-install all my OS (Linux Mint 20.3). This wasn't a problem, since I need to re-import all my databases from a previously created .sql dump that I've created before starting the process of cleaning my computer.

I've used phpMyAdmin to create a full dump of my MySQL server. But, after fully reinstalling my OS, softwares and MySQL Server (version 8.0.27), I can't re-import my .sql dump.

Tried using CLI mysql command ( mysql -u raphael < localhost.sql ) and directly from phpMyAdmin web interface, but I'm always receiving the following error:

ERROR 2013 (HY000) at line 17476: Lost connection to MySQL server during query

This dump has some Wordpress databases, and the content at line 17476 is that:

ALTER TABLE `wp_posts`
  ADD PRIMARY KEY (`ID`),
  ADD KEY `post_name` (`post_name`(191)),
  ADD KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`),
  ADD KEY `post_parent` (`post_parent`),
  ADD KEY `post_author` (`post_author`);

It's a very large file (aprox. 2.116.647 lines) and it's crucial to me to restablish all databases, because most of them are related to my work.

I've already tried to edit the /etc/mysql/my.cnf file, adding the following content:

[mysqld]
max_allowed_packet = 512M
connect_timeout = 600

But the problem still persists.

Can someone please help me?

Thanks!

I've tried a lot of things, and finally (I think) figured out WHY and HOW to fix this.

I've found somewhere in the internet someone that said "after upgrading from MySQL Server 5.7 to 8.0, phpMyAdmin is corrupting my dumps"... In my case, I've already using MySQL Server 8, but this made me think about...

So, I tried to create a VirtualBox VM with any Linux distro (I've used Ubuntu Server, but doesn't matter), installed MySQL 5.7 (downloaded from here ) and tried to restore my.sql file. I'm surprised that worked fine. After that, I've used the CLI mysqldump to re-create all my localhost dump (from VirtualMachine), and imported the resulting.sql file inside my working machine, and all worked fine.

So, phpMyAdmin was the problem, even using the latest version downloaded directly from official website . There's something in phpMyAdmin (maybe a configuration that I don't know about, or a bug, or something else) that causes dumps from MySQL 8 to be corrupted, wrong file formatting, or maybe the moon isn't aligned with Jupiter and Venus... Is the first time this happens to me.

Thank you for all support, comments and ideas. I really don't know if this solution was the best (or the correct), but it was the only thing that worked for me. Maybe other people can take benefits with this solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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