Why: This happens when querying a database in MySQL, or modifying a larger table;
Google's:
Scenario 1. Add a line under MySQL configuration file [Myslqd] to set skip-name-resolve. The MySQL service needs to be restarted.
Scenario 2: Add an IP to host name mapping in the Hosts file, such as: 127.0.0.1 localhost. This is not a way to restart the MySQL service.
---------------------------
Solve this problem at three levels:
1. At the code level, you need to add roughly the following code to your PHP database connection.
if (In_array (Mysql_errno (), Array (2006, 2013))) {
Mysql_close ();
Mysql_connect (...);
mysql_query (...);
}
In other words, you can reconnect MySQL if you encounter a 2006,2013 error.
2. mysql level, need to configure some parameter my.cnf (but here is Linux, what about my Windows configuration?) )
Wait_timeout = x Timeout time of 600 seconds
Max_allowed_packet = y Maximum allowable data volume
Increase the value of x, y appropriately.
3. Generally this is not the case for all the sentences but a single table, please fix the table in general can solve such problems.
----------------------
MySQL Error 2013:lost connection to MySQL server during query
Error code: 1153-got A packet bigger than ' Max_allowed_packet ' bytes
Workaround:
Modify Mysql.ini (online is said to be this file, looked for n long finally know where, my directory is in D:\MySQL_Data\MySQL Server 5.5 under the Mysql_data folder) file add the following code can be
max_allowed_packet=500m
Modify D:\MySQL\MySQL Server 5.5\my-huge.ini if you can't.
The max_allowed_packet=16m in the 16 change to 500.
I did it according to this method, try it.
----------------------
4. You can set it directly in MySQL:
#show variables like '%timeout% ';
#show variables like ' max_allowed_packet '
Set global wait_timeout=60000;
#set Global max_allowed_packet = 2*1024*1024
MySQL MySQL lost connection to server during query problem solving method