mysqlクライアント立ち上げに失敗する。error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'

mysqlサーバを立てて、クライアントを立ち上げるもつながらない。

# /usr/local/mysql-5.5.27/bin/mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

mysql.sockにつなげないらしい。
調べてみると、mysqladminでどこにあるかわかるみたい。

# /usr/local/mysql-5.5.27/bin/mysqladmin version
/usr/local/mysql-5.5.27/bin/mysqladmin Ver 8.42 Distrib 5.5.27, for Linux on x86_64
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Server version 5.5.27
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 4 min 23 sec

設定ファイルを見てみると、、、

# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

/tmp/mysql.sockに直してあげると、無事起動。

http://dev.mysql.com/doc/refman/4.1/ja/problems-with-mysql-sock.html
https://dev.mysql.com/doc/refman/4.1/ja/option-files.html