6

How does one change the default socket used by mysqladmin?

I don't see a section for [mysqladmin] in /etc/my.cnf.

It tries by default to connect to /tmp/mysql.sock, however, this is not the socket that my MySQL server uses, so I get the error:

error: 'Can't connect to local MySQL server through 
    socket '/tmp/mysql.sock' 

I know you can specify the socket at the command line, such as:

mysqladmin --socket='/some/other/path/mysql.sock'

How do I change the default socket used by mysqladmin so I don't have to specify my non-standard path each time?

2 Answers 2

2

Better yet, make that section [client] to cover for any mysql client call. as this will only work for mysqladmin

2

Add a [mysqladmin] section in your /etc/my.cnf or $USER/.my.cnf and set the socket. This will override the compiled-in socket and the socket defined in the [mysqld] section.

You should be able to figure it out from what's shown below:

VM52-CentOS58[root@ivdb41 ~]# mysqladmin ping

mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql2.sock' (2)' Check that mysqld is running and that the socket: '/var/lib/mysql/mysql2.sock' exists!

VM52-CentOS58[root@ivdb41 ~]# grep -A 1 mysqladmin /etc/my.cnf

[mysqladmin]
socket=/var/lib/mysql/mysql2.sock

VM52-CentOS58[root@ivdb41 ~]# mysqladmin ping mysqld is alive

VM52-CentOS58[root@ivdb41 ~]# grep -A 1 mysqladmin /etc/my.cnf

[mysqladmin]
# socket=/var/lib/mysql/mysql2.sock
1
  • Yes, putting this in the [client] section does indeed also solve his issue. I completely failed to mention that I was assuming (ugh, that word) that he only wanted this to apply to mysqladmin. To the OP, heed TechieGurl's comment that you can make this apply to all client apps by proper section placement of this socket override.
    – Todd Lyons
    Sep 13, 2012 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.