Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

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

share|improve this answer
add comment

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
share|improve this answer
    
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 '12 at 16:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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