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?

robguinness
  • 321
  • 1
  • 4
  • 9

2 Answers2

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
Hannah Vernon
  • 70,928
  • 22
  • 177
  • 323
Todd Lyons
  • 121
  • 3
2

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

TechieGurl
  • 736
  • 5
  • 8