Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't connect to local MySQL server through socket '/tmp/mysql.sock'

Status
Not open for further replies.

sonun

IS-IT--Management
Dec 26, 2001
384
US
I get this error when I try to gte to mysql,
# mysql -u root -p
Enter password:
ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Now there is no mysql.sock in /tmp. I have a mysql running on another server which does have a /tmp/mysql. But when I opne it, it seems to be empty and read only. When I try to copy it, Iget,
cp: cannot open `/tmp/mysql.sock' for reading: No such device or address
Well that pretty much means thatg I simply canot copy somebody else's mysql.sock from another server to this servre.
But what should I do about this.
Please advise.
 
Do you want to connect to the other servers MySQL? Or the local servers? //Daniel
 
Local server's mysql. I can connect to the other server's mysql by ssh'ing into it and then the usual. I dont coonect to other server's mysql directly through the command prompt, I do so through phpmyadmin.
But the main question is to connect to the local mysql server. When I try to do so,I get this error.
Thanks.
 
It seems as if MySQL isn't running on the local server. Try starting it with /etc/init.d/mysql start or just /sbin/service mysql start. //Daniel
 
Well, seems like it does !!

#/usr/local/mysql/bin/safe_mysqld start
A mysqld process already exists

???????????????????????????????
 
look's like your sock file is locate somewhere else
one of the possible locations is /var/lib/mysql/

if so, you have two possibilities - change the mysql startup script safe_mysql that it creates the sock file in the location used by the clients or edit/create /etc/my.cnf that it contains something like this

[client]
socket = /path/to/mysql.sock

[mysqld]
socket = /path/to/mysql.sock

hope that helps
 
I dont know what I did now but it works now.
But before closing this thread, whats in mysql.sock ?? Even when I open as root, I get a
"/tmp/mysql.sock" [Permission Denied]
Why not display even if its assembly language gibberish ??
Or is it just supposed to open a empty file.
Thanks.
 
that 's fine - but you should try to find out was was the solution, maybe you'll come into the same situation later

as i wrote in another thread:
"the purpose of sock files is to make an "interface" between client apps and the server on the local machine (it's like ports when communicating remotely) - when you run "mysql -u user -ppasswd", the client app connects to the mysql daemon through the mysql.sock file"
 
ok, I will try to recollect what I did. I looked into my history as well.
All I seemed to do was a few,
/usr/loca/mysql/bin/safe_mysqld stop
/usr/loca/mysql/bin/safe_mysqld start
/usr/loca/mysql/bin/safe_mysqld restart
in a very random order. Somewhere along there it worked.
Thanks.
 
Has anyone found the solution to this problem? I am
getting the same exact error message, and havent been
able to find a single resource anywhere that gives
any info on the resolution.

I cannot get the mysqld (daemon) to start no matter
what I have tried.

Regards,
Tj

"ERROR 2002: Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)"
 
BigTeejay:

Look if you have a mysql process running (Unix e.g. ps -ef|grep mysq).

Then check if your mysql.sock is in the path that the Error message points, if it doesnt there may be is in anywherelse, so edit your my.cnf file and point the sock = to the path that the error message is pointing to and rester your server (e.g. /path-to-mysql/bin/safe_mysql &).

regards!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top