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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 21:48:14  来源:igfitidea点击:

Ubuntu 11.04 - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)

ubuntuubuntu-11.04mysql

提问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-logprofas root, nothing changed, got angry and then re-set it started working.

让它工作,虽然我不确定如何。我照做aa-logprofroot,没有任何改变,生气了,然后重新设置它开始工作。

采纳答案by sarnold

You cannot (absolutely cannot) replace the filesystem pipe /var/run/mysqld/mysql.sockwith 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.

如果文件系统权限配置正确,您的访问可能会被 强制访问控制工具(例如 AppArmorSELinuxTOMOYOSMACK )拒绝

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.logor dmesg(1)output for messages that look something like this:

AppArmor 默认预装在 Ubuntu 系统上,可能会拒绝访问管道。检查/var/log/syslog/var/log/audit/audit.logdmesg(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.sockinstead.)

(但用name=/var/run/mysqld/mysql.sock代替。)

If you have error messages like this, run aa-logprofas rootand 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_safecreated a new mysqld.sockfile.

就我而言,运行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 mysqldis 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 ?