MySQL 无法连接到Mysql服务器;无法创建/写入 pid 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15408643/
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
Cant connect to Mysql server ; Can't create/write the pid file
提问by Nauman Bashir
Hello I cant seem to connect to my mysql server, i get the following error
您好,我似乎无法连接到我的 mysql 服务器,出现以下错误
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
when i checked the logs , it showed me the following :
当我检查日志时,它显示了以下内容:
130314 12:36:16 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Table 'plugin' is read only
130314 12:36:16 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
130314 12:36:16 InnoDB: Initializing buffer pool, size = 8.0M
130314 12:36:16 InnoDB: Completed initialization of buffer pool
130314 12:36:16 InnoDB: Started; log sequence number 13 1336891001
130314 12:36:16 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/lib/mysql/live.pid' (Errcode: 13)
130314 12:36:16 [ERROR] Can't start server: can't create PID file: Permission denied
回答by khaintt
I had sample problem with mysql. I run under root permission but don't known why this error happen. The problem is mysql user don't have permission to create pid file in /var/run/mysqld
.
Full log could look like:
我有 mysql 的示例问题。我在 root 权限下运行,但不知道为什么会发生此错误。问题是 mysql 用户无权在/var/run/mysqld
. 完整日志可能如下所示:
140812 09:35:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140812 9:35:53 InnoDB: Initializing buffer pool, size = 8.0M
140812 9:35:53 InnoDB: Completed initialization of buffer pool
140812 9:35:53 InnoDB: Started; log sequence number 0 197396648
140812 9:35:53 [ERROR] /usr/libexec/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13)
140812 9:35:53 [ERROR] Can't start server: can't create PID file: Permission denied
140812 09:35:53 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
So the solution is assign mysql user to this directory:
所以解决方案是将mysql用户分配到这个目录:
# chown mysql:mysql /var/run/mysqld
and then start mysqld
然后启动mysqld
# service mysqld start
回答by Sumit
I had the same problem under Redhat and this pagehad the steps to switch the mysql directory.
我在 Redhat 下也有同样的问题,这个页面有切换 mysql 目录的步骤。
service mysqld stop
mkdir /srv/mysql/
chown mysql:mysql /srv/mysql
edit /etc/mysql/my.cnf
and set datadir=/srv/mysql
& socket=/srv/mysql/mysql.sock
编辑/etc/mysql/my.cnf
和设置datadir=/srv/mysql
&socket=/srv/mysql/mysql.sock
Additional steps are required if you are using SELinux and then finally start the server
如果您使用的是 SELinux 然后最后启动服务器,则需要额外的步骤
service mysqld start
回答by Luis Sanchez
In some cases, this error is because we have wrong permissions in log file /var/log/mysqld.log
在某些情况下,这个错误是因为我们在日志文件 /var/log/mysqld.log 中有错误的权限
chown mysql:mysql /var/run/mysqld
回答by Darth Jon
After 2 hours of missing quality Netflix programming I just went ahead and:
在错过了 2 个小时的高质量 Netflix 节目后,我继续前进:
chmod -R 777 /usr/local/mysql
chmod -R 777 /usr/local/mysql-5.6.19-osx10.7-x86_64
... on OSX Mavericks. PITA.
...在 OSX Mavericks 上。皮塔饼。