2 users resposed " Can’t connect to local MySQL server through socket /tmp/mysql.sock "

"Can’t connect to local MySQL server through socket /tmp/mysql.sock" was posted by admin and received 2 users commented
Programare Sociala said,         
January 7 2008

Bulshiiiiiiiiittttt!!!! :D

When the application and the mysql database reside on the same machine, you can forget about connecting through network sockets (which is the equivalent of connecting to IP: 127.0.0.1) and you should instead try connecting through a local file called mysql.sock.

The place of the file (mysql.sock) depends on the mysql build/linux distro.

Regarding that file two things should be taken into account:
1. Know exactly where that file resides.
2. Make sure the rights on that bastard (I mean mysql.sock) are properly set. You should have a user/group “mysql” with rights on that file.

Now… if you can’t connect to the database you can quickly check its status and (also important) the parameters.

You can do that with a command like:
ps -ef | grep mysqld

if you get no result, then the server wasn’t able to start.

If you get results, then you should have something like:
/usr/libexec/mysql/mysqld –basedir=/usr –datadir=/var/lib/mysql –user=mysql –pid-file=/var/run/mysql/mysql.pid –skip-external-locking –port=3306 –socket=/var/run/mysql/mysql.sock

Option –port=3306 makes sure you can access the database from remote machines. Ofcourse you need firewall access and also most probably an username/password. Also in the cnf file you should comment out “bind-address = 127.0.0.1″ which will make mysqld listen on localhost ONLY.

Option –socket=/var/run/mysql/mysql.sock tells you where is the socket located, and also tells you that this file connection mode is available.

In order

P.S. After you set up the password on the database you can’t connect to it without adding 2 parameters to the mysql client.

So, instead of using: mysql with no parameters try:
mysql -u root -p
then type the password.

admin said,         
January 7 2008

aia e bullshit pentru noobs in situatia in care nu se foloseste cpanel or stuff :)

Welcome stranger, please leave your comments below

  Username (required)

  Email (required)

  Website

leave your comments below

Subsribes to this topic Comment Rss or TrackBack

Subscribe without commenting