Make sure that the server is running, if not, the client can't connect to it, for example, if unsuccessful in his attempt to connect to the server, and displays a message, one of the following information, the reason may be the server is not running:
Shell> Mysql
ERROR 2003: Can 't connect to MySQL server on' host_name '(111)
Shell> Mysql
ERROR 2002: Can 't connect to local MySQL server through socket
'/TMP/mysql. The sock' (111)
May be a server is running, but you try to use as the name of the server is listening on the TCP/IP port for the pipe connect or Unix socket files, in the calling client application, to correct the problem, please specify a - port option to indicate that the correct port number, or - socket specify the appropriate named pipes or Unix socket file option, to find the location of the socket file, you can use the following command:
Shell> Netstat ln | grep mysql
To ensure that the server is not configured to ignore the network connection, or (if you try to remote connection), then the server has not been configured for local listening on the network interface, only if the server startup - skip - networking, it will not accept the TCP/IP connection, if the server is started, the bind - address=127.0.0.1, it will only listen to locally on loopback interface of TCP/IP connection, and will not receive a remote connection,
Check to make sure that no firewall blocking access to MySQL, your firewall may be on the basis of executing application configuration, may also be a MySQL for communication port (default is 3306), under Linux or Unix, check your IP tables (or similar) configuration, to ensure that the port is not to stop, under Windows, such as ZoneAlarm or Windows firewall applications may need to be configured to not stop MySQL port,
Authorization table must be set up correctly, so that the server can use them to access control, for some distribution types (such as binary distributions on the Windows or Linux on RPM distribution), the installation process will be initialized MySQL data directory, including the MySQL databases in the authorization table, for release, don't do this, you must manually initialize data directory,
To determine whether to need to initialize the authorization table, please find the mysql data directory in the directory, data directory (usually named data or var in your mysql installation directory), make sure you have a user. The MYD in mysql database naming files in the directory, if not, please to initialize the data directory,
CodePudding user response:
Unable to connect to MySQL server on the host_name