snippetsqlModerate
How to define custom path to MySQL socket file?
Viewed 0 times
pathfilecustommysqldefinehowsocket
Problem
I have following config
So, there is a custom path to the socket file
MySQL server works but I cannot connect to it.
but needed file is exists.
When path to the socket file is
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql-socket/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
innodb_buffer_pool_size=64M
innodb_log_file_size=16M
[mysqld_safe]
log-error=/var/log/shared/mysqld.log
pid-file=/var/run/mysqld/mysqld.pidSo, there is a custom path to the socket file
/var/lib/mysql-socket/mysql.sock.MySQL server works but I cannot connect to it.
$ mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)but needed file is exists.
$ ls /var/lib/mysql-socket/mysql.sock
/var/lib/mysql-socket/mysql.sockWhen path to the socket file is
/var/lib/mysql/mysql.sock it works fine.Solution
Your error message says it's connecting to the wrong socket:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
You can either specify that in command line:
Or in the my.cnf file under the client section (this can also be in users home directory
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
You can either specify that in command line:
mysql -S /var/lib/mysql-socket/mysql.sock ...Or in the my.cnf file under the client section (this can also be in users home directory
~/.my.cnf):[client]
socket=/var/lib/mysql-socket/mysql.sockCode Snippets
mysql -S /var/lib/mysql-socket/mysql.sock ...[client]
socket=/var/lib/mysql-socket/mysql.sockContext
StackExchange Database Administrators Q#152755, answer score: 13
Revisions (0)
No revisions yet.