Ubuntu 11.04 - 无法通过套接字“/var/run/mysqld/mysqld.sock”连接到本地 MySQL 服务器 (13)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8240287/
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
Ubuntu 11.04 - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)
提问by Jamie Hutber
I have googled for 2 days now and was initially get a
我已经用谷歌搜索了 2 天,最初得到了一个
'/var/run/mysqld/mysqld.sock' (2)
I fixed this by using:
我通过使用解决了这个问题:
sudo touch /var/run/mysqld/mysqld.sock
sudo chown -R mysql /var/run/mysqld/
now i get the error:
现在我得到错误:
'/var/run/mysqld/mysqld.sock' (13)
So everything has the correct permissions and the file exists. Any thoughts?
所以一切都具有正确的权限并且文件存在。有什么想法吗?
[Edit]
[编辑]
Got it working, although i am unsure how. I did aa-logprof
as root
, nothing changed, got angry and then re-set it started working.
让它工作,虽然我不确定如何。我照做aa-logprof
了root
,没有任何改变,生气了,然后重新设置它开始工作。
采纳答案by sarnold
You cannot (absolutely cannot) replace the filesystem pipe /var/run/mysqld/mysql.sock
with a regular file. You need to use mkfifo(1)
to create the pipe(7)
that clients use to communicate with the mysql server.
您不能(绝对不能)用/var/run/mysqld/mysql.sock
常规文件替换文件系统管道。您需要使用mkfifo(1)
来创建pipe(7)
客户端用于与 mysql 服务器通信的对象。
The (13)
probably alsomeans that you have a permission deniederror return, EACCES
(which usually has the decimal value 13
-- yes, I've seen it a lot).
这(13)
可能也意味着您有一个权限被拒绝的错误返回,EACCES
(通常有十进制值13
——是的,我见过很多)。
If the file system permissions are configured correctly, you might be having accesses rejected by a mandatory access controltool such as AppArmor, SELinux, TOMOYO, or SMACK.
如果文件系统权限配置正确,您的访问可能会被 强制访问控制工具(例如 AppArmor、SELinux、TOMOYO或SMACK )拒绝。
AppArmor comes pre-installed on Ubuntu systems by default, and might be rejecting access to the pipe. Check /var/log/syslog
, /var/log/audit/audit.log
or dmesg(1)
output for messages that look something like this:
AppArmor 默认预装在 Ubuntu 系统上,可能会拒绝访问管道。检查/var/log/syslog
,/var/log/audit/audit.log
或dmesg(1)
对消息输出是这个样子:
type=AVC msg=audit(1320723925.179:45115): apparmor="DENIED"
operation="open" parent=1 profile="/usr/sbin/ntop"
name="/usr/share/ntop/html/PlotKit/excanvas.js" pid=1835 comm="ntop"
requested_mask="r" denied_mask="r" fsuid=122 ouid=0
(But with name=/var/run/mysqld/mysql.sock
instead.)
(但用name=/var/run/mysqld/mysql.sock
代替。)
If you have error messages like this, run aa-logprof
as root
and answer the questions. More information on configuration AppArmor can be found in the apparmor.d(5)
manpage, or some various wiki pages.
如果你有这样的错误信息,运行aa-logprof
作为root
并回答问题。有关配置 AppArmor 的更多信息可以在apparmor.d(5)
联机帮助页或一些不同的 wiki 页面中找到。
回答by aviggiano
In my case, running mysqld_safe
created a new mysqld.sock
file.
就我而言,运行mysqld_safe
创建了一个新mysqld.sock
文件。
$ cd /etc/init.d/
$ mysqld_safe
You'll probably won't get the prompt back, but if you restart your session, a mysqld.sock file will be somewhere. Find it with
您可能不会得到提示,但如果您重新启动会话,mysqld.sock 文件将在某处。找到它
$ sudo find / -type s | grep mysqld.sock
回答by wallyk
Did you check that the mysql server mysqld
is running? Also, check the system message log to see if it is complaining about anything.
您是否检查过 mysql 服务器mysqld
正在运行?此外,检查系统消息日志以查看它是否有任何抱怨。
回答by Edouard B
Did you try to remove .lock file and restart mysqld ?
您是否尝试删除 .lock 文件并重新启动 mysqld ?