Search the MySQL manual:

A.2.3 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, if the mysqld server is running on 9x/Me, you can connect only via TCP/IP. If the server is running on NT/2000/XP and mysqld is started with --enable-named-pipe, 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. See section 2.4.2 Problems Starting the MySQL Server.

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 --protocol=socket --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 :

User Comments

Posted by Linda Wright on Tuesday August 13 2002, @7:17pm[Delete] [Edit]

If you have just done a manual modification of
mysql db permissions or a source load into a
database which alters permissions to allow remote
connections etc., you will need to do a "mysqladmin
reload" on the database before the changes will take
effect. This is particularly important when configuring
remote access permissions - connection attempts
will not be allowed using new permissions even
though the mysql records look perfect.
Remembering to use the mysqladmin reload
command can save a lot of needless debugging.

Posted by George Stavroulakis on Sunday September 22 2002, @2:23pm[Delete] [Edit]

For Win9x/Me/2000/XP platform: I had an error
description like "ERROR 2003: Can't connect to
MySQL at 'localhost' (10063)" but could not get rid
of with the usual ways. The mysqld-nt service was
running but I had no connection. The problem was
that I had accidentally erased my "share" directory
and the mysqld-nt service was up but NOT running
as it was trying to find the share directory. Since it
was not running, it could NOT respond to socket
requests, hence the error with the 10063 code. To
sum up, if you have this error check out if all the
folders are in place...

Posted by Amy Law on Tuesday October 1 2002, @10:38pm[Delete] [Edit]

I had the problem with "*ERROR 2003: Can't
connect to MySQL server on 'localhost' (10061)*"
and here is how I resolved the issue. I thought I
would share my solution with you...

1. Uninstalled mysql (I guess my first installation
was corrupted).

2. c:\mysql\bin>mysqld-nt.exe --install

3. Reboot

4. Now, check the task manager and mysqld-nt.exe
should be running at the background. If not, there is
something wrong with the install -- I believe
it was my problem.

5. C:\mysql\bin>mysql -u root mysql

6. mysql> set password for
root@localhost=PASSWORD("funfun");

7. mysql> update user set password=PASSWORD
("funfun") where user='root';

8. mysql> flush privileges;

Note that funfun is my password

Posted by Mike Discenza on Tuesday November 26 2002, @11:29am[Delete] [Edit]

I've received "ERROR 2003: Cannot connect to MySQL
server on '<server_name>' (111)" when the loopback
has multiple addresses configured. One address
for 127.0.0.1 and at least one other address. As
soon as the alias for the loopback was removed I
was able to connect. This happened on a RH7.3 server.

Posted by Siegfried Löhr on Tuesday December 3 2002, @1:43am[Delete] [Edit]

By chance one has changed the
mysql_default_socket value in php.ini. It was set to
the document root path of my web server. This led
to error 2002 "Can't connect to local MySql server..."
After removing the value everything was fine again.

Posted by [name withheld] on Saturday March 1 2003, @3:41pm[Delete] [Edit]

Sometimes you just have to comment out "skip-networking" in /etc/mysql/my.cnf and restart mysql.

Posted by Raj Rossrakesh on Tuesday March 4 2003, @9:45pm[Delete] [Edit]

I was having probs when trying to setup mysql control centre on my windoze 2000 box. Iam getting this msg.....
[Mysql] ERROR 2013: Lost connection to MySQL server during query

MYSQL server running on Redhat 8
Shell> mysqladmin version
mysqladmin Ver 8.23 Distrib 3.23.52, for pc-linux-gnu on i686
Server version 3.23.52
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 4 min 52 sec

Threads: 1 Questions: 3 Slow queries: 0 Opens: 6 Flush tables: 1 Open tables: 0 Queries per second avg: 0.010


just the line
set-variable = thread_stack=256K
in my.cnf
restart MySQL server

don't forget to give access to hosts other then the localhost as well
grant all privileges on *.* to dbusername@192.168.1.% identified by 'dbpass';


Posted by Sergio Salgueiro on Wednesday March 5 2003, @11:35am[Delete] [Edit]

Usually, the /etc/my.cnf file points to /var/lib/mysql/mysql.sock for the socket file.

Changind the pointers to /tmp/mysql.sock will
make apache work.

Posted by Oliver Chen on Saturday March 8 2003, @11:29pm[Delete] [Edit]

I'm trying to connect to a database running off a W2K server from my Linux 8.0. Both machines have mysql server installed and running properly. However when I type in the Linux box the command: mysql -h id_address -u user_name, I'd get this error message:
ERROR 2003: Can't connect to MySQL server on '63.202.128.121' (110)

This error won't happen if I connect from a W2K Professional workstation. Any idea why this happens?

Posted by Dave Baker on Saturday March 15 2003, @8:42pm[Delete] [Edit]

If your socket file is /var/lib/mysql/mysql.sock, be sure the /var/lib/mysql directory is world-readable and world-writable -- otherwise PHP (e.g. vBulletin) or some other application trying to use that socket (via the web server, running as www or apache or some similarly restricted user) to use MySQL won't be able to, and your web users will see the dreaded MySQL-generated error message ("I'm sorry ...").

This probably isn't a problem with sockets that are created in the /tmp directory, which is probably world-readable and world-writable from the get-go.

Posted by [name withheld] on Thursday April 3 2003, @7:51am[Delete] [Edit]

Those having problems connecting on Redhat Linux unless logged in as root, the problem can be solved thusly:

chmod 755 /var/lib/mysql

Posted by yannick boussemart on Monday April 7 2003, @7:07am[Delete] [Edit]

[function.mysql-connect]: Can't create TCP/IP socket (10106)
Trying to connect to mysql with PHP under windows XP pro.
The solution to this problem was for me to connect
.via named pipe (FIFO)
in the my.ini, I added this:
enable-named-pipe
and renamed localhost:
HOST=.
(just a dot) and not
HOST=localhost
which, if I anderstand well try to find its way via TCP/IP and for some reason doesn't.
I overlooked the installation manual.
Everything works just fine now.
Hope I helped someone.
Yannick Boussemart

Posted by David White on Wednesday May 7 2003, @8:38am[Delete] [Edit]

ERROR 2003: Can't connect to
MySQL at 'localhost' (10063)"

I had to edit the my.ini file and un-rem the 'port=3306' line. It worked. I'm wondering if something changed because I installed Dreamweaver MX, trying to use with PHP? Hmmm. I didn't have to un' or reinstall mysql.

Posted by kamal monga on Wednesday May 28 2003, @2:53am[Delete] [Edit]

well, goto mysql folder
goto 'bin' folder in mysql folder
run winmysqladmin.exe
and a thing popup and after few second it goes off well dont be scared u see the traffic thingy below?
well right click that and click "Show Me"
u'll see some thingys
Below u see one picture "Power by Mysql" and below is Extended Server Status
click that
then click on Hide me
and when u see that traffic below agin
right click and if u see a "Win 9x" or "Win NT" and when u mouseover it and 3 options came out "ShutDown this tool","shutdown server","shutdown both" click on Shutdown tool ONLY and try if it can works
this is wat i did to make the mysql works, if there is problem just ask here... monga_kamal@rediffmail.com

Posted by [name withheld] on Sunday June 1 2003, @12:26am[Delete] [Edit]

Followed Mike Discenza's method and still do not see mysqld-nt running. Grr. Amy mentioned the "share" folder. Where is that, exactly?

Posted by Michael W. Dietrich on Monday June 9 2003, @1:22am[Delete] [Edit]

after installation for what reasons ever I got "Cannot connect to MYSql Server on localhost (10061)" I found out, that in the my.ini file in the Windows directory there was an entry

bind-address=192.168.0.3

which made it possible to connect to mySQL on 192.168.0.3 but not on "localhost" which resolves to 127.0.0.1

after commenting that out it looked like

#bind-address=192.168.0.3

and I was able to connect on both 192.168.0.3 and localhost.

Posted by Alex on Wednesday June 25 2003, @9:50am[Delete] [Edit]

have some problems-- Warning: mysql_connect(): Can't connect to MySQL server on 'localhost' (10061)?
Three days i'm tring edit all config files of Apachee & PHP.
But a problem was a simple....
I have a Firewall programm. And it's bloking MySQL port.
After unbloking port, All working !!!

Add your own comment.