MySQL Database common error problem answer

Source: Internet
Author: User
Tags socket time limit mysql database port number

18.2.1 MySQL server has gone away error

This section also covers errors about lost connection to server during query.

The most common cause of gone away errors for MySQL server has is that the server timed out and closed the connection. By default, if nothing happens, the server closes the connection after 8 hours. You can change the time limit by setting the Wait_timeout variable when starting mysqld.

You can check that MySQL is not dead by executing mysqladmin version and checking uptime.

If you have a script, you just have to issue a query to get the guest to reconnect again.

In this case, you usually get the following error codes (you get OS related):

Cr_server_gone_error customers cannot send a problem to the server.

Cr_server_lost when writing a server, the customer does not have an error, but it does not get a complete answer to the question (or any answers).

If you send an incorrect or too large query to the server, you may also get these errors. If Mysqld gets a packet that is too large or not normal, it thinks the customer has made a mistake and closes the connection. If you need a larger query (for example, if you are working on a larger BLOB column), you can use the-O max_allowed_packet= #选项 (default 1M) to start mysqld to increase the query limit. Excess memory is on demand, so mysqld uses more memory only if you make a big difference or mysqld must return a larger result row!

18.2.2 Can ' t connect to [local] MySQL server error

A MySQL customer can connect to a MYSQLD server in two different ways: a UNIX socket, which is connected by a file in the file system (the default "/tmp/mysqld.sock"), or TCP/IP, which is connected through a port number. UNIX sockets are faster than TCP/IP, but are used only on servers that connect to the same computer. If you do not specify a host name or if you specify a special hostname localhost, use UNIX sockets.

Error (2002) Can ' t connect to ... Usually means that no MySQL server is running on the system or when trying to connect to the MYSQLD server, you are using an incorrect socket file or TCP/IP port.

By checking (using PS) there is a process on your server named Mysqld that starts! If there is no mysqld process, you should start one. See 4.15.2 to start the MySQL server issue.

If a mysqld process is running, you can check the server by trying these different connections (of course, the port number and socket pathname 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 inverted quote "'" instead of the positive quotation mark "'", which causes the hostname output (that is, the current hostname) to be substituted for the mysqladmin command.

This is some of the reasons why can ' t connect to the local MySQL server error:

Mysqld is not running.

You are running on a system that uses mit-pthreads. If you are running on a system that does not have a native thread, MYSQLD uses the Mit-pthreads package. See 4.2 Operating systems supported by MySQL. However, Mit-pthreads does not support UNIX sockets, so when connecting to a server, you always have to specify the hostname explicitly on such a system. Try using this command to check the connection to the server:

shell> mysqladmin-h ' hostname ' version

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.