MySQL 如何更改mysql.sock?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5832266/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change mysql.sock?
提问by rajesh
I have installed mysql through binary installation and followed below steps http://dev.mysql.com/doc/refman/5.0/en/binary-installation.html
我已经通过二进制安装安装了 mysql,并按照以下步骤 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.
现在,当 mysql 服务启动时,sock 文件在 /tmp/mysql.sock 上创建。
I want to know which configuration files need to be edited to change the path of mysql.sock
我想知道修改mysql.sock的路径需要修改哪些配置文件
I tried the following steps to change mysql.sock path from /tmp/mysql.sock to /var/lib/mysql/mysql.sock
我尝试了以下步骤将 mysql.sock 路径从 /tmp/mysql.sock 更改为 /var/lib/mysql/mysql.sock
1.I tried to enter socketpath in /etc/my.cnf
1.我尝试在/etc/my.cnf中输入socketpath
socket =/var/lib/mysql/mysql.sock
2./etc/init.d/mysql
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.
任何人都可以帮我解决这个问题。
回答by Rudi Visser
Setting these variables in my.cnf should work just fine (Tested locally, Ubuntu 10.10).
在 my.cnf 中设置这些变量应该可以正常工作(本地测试,Ubuntu 10.10)。
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
Just make sure you're restarting MySQL Service?
确保您正在重新启动 MySQL 服务?
Below is what I did, this is on Fedora (Since you're using RHEL this should more mimic your setup):
下面是我所做的,这是在 Fedora 上(因为您使用的是 RHEL,这应该更模仿您的设置):
[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.
我唯一改变的是socket=
这次,重新启动仍然可以正常工作。
Are you sure that you're not editing socket
within the [client]
section of my.cnf
? It must be under the [mysqld]
section.
您确定不是socket
在 的[client]
部分内进行编辑my.cnf
吗?它必须在该[mysqld]
部分下。