How to change mysql.sock?

百般思念 提交于 2019-12-11 01:35:21

问题


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:


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.



来源:https://stackoverflow.com/questions/5832266/how-to-change-mysql-sock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!