First, the problem description:
MySQL database query, encountered the following error message:
Second, reason analysis:
Dw_user table data volume is large, direct query speed is slow, easy to "card dead", resulting in automatic database connection timeout ....
Third, the solution:
Scenario 1. Add a line under MySQL configuration file [Myslqd] to set skip-name-resolve. The MySQL service needs to be restarted.
Scenario 2: Adding an IP and hostname mapping in the Hosts file [this way does not restart]
For example: In the Hosts file, add:
127.0. 0.1 localhost
Other online methods:
1. At the code level, you need to add roughly the following code to your PHP database connection.
if ( in_array(mysql_errnoarray(2006))) { 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 is 600 seconds = y Maximum allowable data amount
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 -: Lost Connection toMySQL Server during query error code:1153 -Got a packet bigger than'Max_allowed_packet'bytes Solution: Modify the Mysql.ini (online is said to be this file, find n long finally know where, my directory is in the D:\MySQL_Data\MySQL Server5.5in the Mysql_data folder) file add the following code to Max_allowed_packet=500M Modify D:\MySQL\MySQL Server If it is not possible5.5\my-the Max_allowed_packet in Huge.ini.=16M Change 16 to 500 I did it according to this method, try it.
4. You can set it directly in MySQL:
like ' %timeout% ' ; like ' Max_allowed_packet ' set global wait_timeout=60000; #Set=2*1024x768*1024x768
Solution for "Lost connection to MySQL server during query" error when querying in MySQL