//// move dir
# mv /var/libmysql /mnt/data/
//// vi /etc/my.cnf
【mysqld】 // 服务器端
datadir=/mnt/data/mysql
socket=/mnt/data/mysql/mysql.sock
【mysql】 // 客户端
socket=/mnt/data/mysql/mysql.sock
/// restart to check
/// need to update config in /etc/php.ini
pdo_mysql.default_socket=/mnt/data/mysql/mysql.sock
mysql.default_socket = /mnt/data/mysql/mysql.sock
mysqli.default_socket = /mnt/data1/mysql/mysql.sock
/// reference : http://www.aiezu.com/db/mysql_cant_connect_through_socket.html
原文地址:http://huangchao.blog.51cto.com/10446378/1708262