Sunday, August 1, 2010

MySQL connecting issue.

Mysql issue

Hi friends...
I just install the mysql becuse of db crashe. After that when i try to connect to the mysql server through the client i got this exception.

Con't connect to local MySQL server through socket.

Finally i found that i need to give the socket path with 'mysql' command.

like this...

mysql --socket=/var/lib/mysql/mysql.sock ...

For the mysql client, the default location of this socket file is /tmp/mysql.sock. However, for a variety of reasons, many MySQL installations place this socket file somewhere else like /var/lib/mysql/mysql.sock.

It is painful to type this in every time.
So i update the /etc/my.cnf file. Add these at the bottom.

[client]
socket=/var/lib/mysql/mysql.sock


Note : If there is already a [client] section in the my.cnf file, add or edit the socket line as appropriate. You won’t need to restart your server or any other processes. Subsequent uses of the mysql client will use the proper socket file.

No comments: