Common MySQL server has gone away errors when using MySQL
This section also contains errors related to Lost connection to server during query.
The most common cause of the MySQL server has gone away error is that the server times out and closes the connection. By default, if nothing happens, the server closes the connection eight hours later. You can change the time limit by setting the wait_timeout variable when starting mysqld.
You can run mysqladmin version and check the normal running time to check that MySQL has not died.
If you have a script, you only need to issue a query to enable the customer service to automatically reconnect again.
In this case, you usually get the following error code (you get OS-related ):
The CR_SERVER_GONE_ERROR client cannot send a problem to the server.
CR_SERVER_LOST when writing data to the server, the customer did not make an error, but it did not get a complete answer (or any answer) to the question ).
If you send incorrect or too many queries to the server, you may also get these errors. If mysqld gets a large or abnormal package, it considers the customer has an error and closes the connection. If you need a large query (for example, if you are processing a large BLOB column), you can use the-O max_allowed_packet = # option (default: 1 M) start mysqld to add query restrictions. Extra memory is allocated on demand. in this way, mysqld uses more memory only when you send a large bad query or when mysqld must return a large result!
Can't connect to [local] MySQL server error
A MySQL client can connect to the mysqld server in two different ways: Unix socket, which uses a file in the file system (default: "/tmp/mysqld. or TCP/IP, which is connected by a port number. Unix sockets are faster than TCP/IP, but only used to connect servers on the same computer. If you do not specify a host name or if you specify a special host name localhost, use a Unix socket.
Error (2002) Can't connect... it usually means that no MySQL server is running on the system or you are using an incorrect socket file or TCP/IP port when trying to connect to the mysqld server.
Started by checking (using ps) a process named mysqld on your server! If there is no mysqld process, you should start one. See 4.15.2 about how to start the MySQL server.
If a mysqld process is running, you can check the server by trying these different connections (of course, the port number and socket path name may be different in your installation ):
Shell> mysqladmin version
Shell> mysqladmin variables
Shell> mysqladmin-h 'hostname' version variables
Shell> mysqladmin-h 'hostname' -- port = 3306 version
Shell> mysqladmin-h ''ip for your host'' version
Shell> mysqladmin -- socket =/tmp/mysql. sock version
Note that the hostname command uses the reverse quotation mark (') instead of the forward quotation mark (''). These causes the hostname output (that is, the current host name) to be replaced by the mysqladmin command.
This is a possible cause of the Can't connect to local MySQL server error: