Can't connect to local MySQL server error.A MySQL client can connect to the mysqld server in two different ways: Unix sockets, which connects trough a file in the file system, (default `/tmp/mysqld.sock'), or TCP/IP which connects trough a port number. Unix sockets are faster than TCP/IP but can only be used when connection to a server on the same computer. Unix sockets are used if one doesn't specify a hostname or if one specifies the special hostname 'localhost'.
Here follows some reasons to the error
Can't connect to local MySQL server.
ps.
You can check the server by trying these different connections: (the port and
socket may of course be different in your setup).
mysqladmin version mysqladmin -h `hostname` version mysqladmin -h `hostname` --port=3306 version mysqladmin --socket=/tmp/mysql.sock version
'mysqladmin -u `hostname` version to check the
connection to the server.
mysqladmin version and
check that the socket mysqladmin is trying to use really exists.
The fix in this case is to change the cron job not to remove mysqld.sock
or to place the socket somewhere else. You can move the socket by reconfiguring
mysqld with ./configure --with-unix-socket-path=/my-own-place/mysql.sock
or starting safe_mysqld with --socket=/my_own_place/mysqld.sock and
setting the environment variable MYSQL_UNIX_PORT to point at the socket
before starting your mysql clients.
--socket=....
If you change the socket you must also notify the clients about the new
path. You can do this by setting the environment variable
MYSQL_UNIX_PORT to point at the socket or provide the socket as a
argument to the mysql clients. You can for example test the socket with
mysqladmin --socket=/path-to-socket version.
Go to the first, previous, next, last section, table of contents.