default socket file wrong socket file name

mysql -usystem -pMypassword
Somehow, it is using wrong socket file when using mysql client to connnect

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/home/mysql/mysql01.sock’

in /etc/my.cnf
I have following
[mysqld]
socket=/home/mysql/mysql.sock

[client]

[mysql]
socket=/home/mysql/mysql.sock

But still mysql client says Socket ‘/home/mysql/mysql01.sock’ while it should be Socket ‘/home/mysql/mysql.sock’

I also checked that I don’t have .my.cnf in my default home dir.
What am I missing ?

Hi sanjay92;

Are you able to connect when you specifying the socket explicitly (–socket=/home/mysql/mysql.sock)?

And what user are you using to connect? root? If so check /root/.my.cnf

-Scott

Yes, I was able to connect using socket syntax.
I have found issue.
There was my.cnf in /opt/mysql/5.1.7 and that’s what causing issue since socket was wrong in this file.

mysqladmin -usystem -pPassword

Shows me following output which gave me clue about issue.
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf /opt/mysql/5.1.7/my.cnf ~/.my.cnf

Thanks a lot.