This error code happens when the MySQL server loses connection to the query. This can happen for a variety of reasons, including but not limited to: the server being down, the network being down, or the query taking too long to execute.
People like you are also looking for:
- mysql error code 2013
- lost connection to mysql server during query
1. Check if the server is running
- Check if the MySQL server is running mysql -u root -p
- Check the status of the MySQL server mysql -V
- Check the log files to see if there are any errors mysql -u root -p < /var/log/mysql/error.log
- Check the status of the mysqld daemon service mysqld status
- Check the status of the mysqld processes ps -ef | grep mysqld
- If necessary, restart the MySQL server or mysqld daemon
2. Check if the server is accessible
- Open a command prompt and change directory to the MySQL installation directory.
- Issue the following command to test your server's connectivity to the MySQL server. mysql -uroot -p
- If the server is accessible, you will see the following response. mysql> SHOW VERSION; mysql Ver 5.6.25-0ubuntu0.14.04.1-log
3. Check if the connection is configured properly
- Verify that the MySQL server is running and accessible.
- Check the server's configuration to ensure that the proper MySQL connection parameters are in place.
- Verify that the MySQL client software is installed and configured correctly.
- If the connection fails, check the network connection and the MySQL server configuration.
If the answers above didn't work then you should also try:
- Check if the query is valid
- Check if the table exists
- Check if the user has permission to access the table
- Check if the user has permission to execute the query