Problem Details (from
mysql documentations, www.mysql.com):
Can't connect to
[local] MySQL server error
A MySQL client on Unix can connect to the mysqld
server in two different ways: Unix sockets, which connect through a file
in the file system (default `/tmp/mysqld.sock') or TCP/IP, which
connects through a port number. Unix sockets are faster than TCP/IP but
can only be used when connecting to a server on the same computer. Unix
sockets are used if you don't specify a hostname or if you specify the
special hostname localhost .
On Windows you can connect only with
TCP/IP if the mysqld server is running on Win95/Win98. If
it's running on NT, you can also connect with named pipes. The name of the
named pipe is MySQL. If you don't give a hostname when connecting to mysqld ,
a MySQL client will first try to connect to the named pipe, and if this
doesn't work it will connect to the TCP/IP port. You can force the use of
named pipes on Windows by using . as the hostname.
The error (2002) Can't connect to
... normally means that there isn't a MySQL server running on the
system or that you are using a wrong socket file or TCP/IP port when
trying to connect to the mysqld server.
Start by checking (using ps
or the task manager on Windows) that there is a process running named mysqld
on your server! If there isn't any mysqld process, you
should start one.
If a mysqld process is
running, you can check the server by trying these different connections
(the port number and socket pathname might be different in your setup, of
course):
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 the use of backquotes rather than
forward quotes with the hostname command; these cause the
output of hostname (that is, the current hostname) to be
substituted into the mysqladmin command.
Here are some reasons the Can't
connect to local MySQL server error might occur:
If you get the error message Can't
connect to MySQL server on some_hostname , you can try the following
things to find out what the problem is :
- Check if the server is up by doing
telnet
your-host-name tcp-ip-port-number and press Enter a couple of
times. If there is a MySQL server running on this port you should get
a responses that includes the version number of the running MySQL
server. If you get an error like telnet: Unable to connect to
remote host: Connection refused , then there is no server
running on the given port.
- Try connecting to the
mysqld
daemon on the local machine and check the TCP/IP port that mysqld
it's configured to use (variable port ) with mysqladmin
variables .
- Check that your
mysqld
server is not started with the --skip-networking option.
|