2

I have installed mysql through binary installation and followed below steps http://dev.mysql.com/doc/refman/5.0/en/binary-installation.html

Right now sock files are craeted on /tmp/mysql.sock when mysql service is started.

I want to know which configuration files need to be edited to change the path of mysql.sock

I tried the following steps to change mysql.sock path from /tmp/mysql.sock to /var/lib/mysql/mysql.sock

1.I tried to enter socketpath in /etc/my.cnf

socket =/var/lib/mysql/mysql.sock

2./etc/init.d/mysql

basedir=/var/lib/mysql
datadir=/var/lib/mysql/data
socket=/var/lib/mysql/mysql.sock

Can anybody help me to fix this issue.

1 Answer 1

4

Setting these variables in my.cnf should work just fine (Tested locally, Ubuntu 10.10).

[mysqld] 
datadir=/var/lib/mysql 
socket=/var/lib/mysql/mysql.sock

Just make sure you're restarting MySQL Service?

Below is what I did, this is on Fedora (Since you're using RHEL this should more mimic your setup):

[root@rudi /]# ls /var/lib/mysql/
ibdata1  ib_logfile0  ib_logfile1  mysql  mysql.sock
[root@rudi /]# ls /var/run/mysqld/
mysqld.pid
[root@rudi /]# nano /etc/my.cnf 
[root@rudi /]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@rudi /]# ls /var/lib/mysql/
ibdata1  ib_logfile0  ib_logfile1  mysql
[root@rudi /]# ls /var/run/mysqld/
mysqld.pid  mysql.sock

The only thing that I changed was socket= this time, and restarting still worked fine.

Are you sure that you're not editing socket within the [client] section of my.cnf? It must be under the [mysqld] section.

3
  • yeah i have restarted the mysql service. whether my.cnf is the only file we need to specify the path ? or any other file ?
    – rajesh
    Apr 29, 2011 at 13:01
  • 1
    I've updated my answer with exactly what I did, and a few more comments. Does this help at all? Apr 29, 2011 at 13:12
  • 1
    If you are seeing this message in /var/log/mysql/errors.log: 130308 13:37:30 [ERROR] Can't start server : Bind on unix socket: Permission denied, you might need to edit /etc/apparmor.d/usr.sbin.mysqld, and change the path of the socket file in there as well.
    – TrinitronX
    Mar 8, 2013 at 21:36

Your Answer

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

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