Heim > Datenbank > MySQL-Tutorial > 2006 – MySQL Server has gone away error during database imp_MySQL

2006 – MySQL Server has gone away error during database imp_MySQL

WBOY
Freigeben: 2016-06-01 13:08:00
Original
1002 Leute haben es durchsucht

I was trying to import a relatively large database into MySQL via phpMyAdmin, and I was hit with the error message 2006 – MySQL server has gone away :

2006-mysql-server-has-gone-away

Why has the server gone away? lol. Thinking it was bound to be something like a size limit ( not the first time this has happened to me ), I ran some simple SQL to print out the MySQL configuration variables:

SHOW VARIABLES;
Nach dem Login kopieren

show-variables-sql

In the resulting list, look for max_allowed_packet :

max-allowed-packet-size

If you convert 1048576 bytes into something perhaps more meaningful, such as MB, you’ll find it’s a low 1MB. Well, that’s certainly not a big enough limit for the database SQL I’d tried to import.

Edit the MySQL my.cnf file

So to increase this limit, I located the my.cnf file, which MAMP uses as part of the MySQL configuration setup:

sudo nano /etc/my.cnf
Nach dem Login kopieren

And added a new value to the end of the file:

max_allowed_packet = 64M
Nach dem Login kopieren

Thanks to this article for helping me understanding how to update the MySQL settings for MAMP , and this answer on stackoverflow for helping me understand why I was received the 2006 sql error.

Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage