缺少 /var/lib/mysql/mysql.sock 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5661069/
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
Missing /var/lib/mysql/mysql.sock file
提问by unleashed
I'm trying to access mysql and when I run the mysql command, I get the following.
我正在尝试访问 mysql,当我运行 mysql 命令时,我得到以下信息。
[root@ip-10-229-65-166 tpdatabase-1.8.0.28356]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@ip-10-229-65-166 tpdatabase-1.8.0.28356]# mysql
ERROR 2002 (HY000): 无法通过 socket '/var/lib/mysql/mysql.sock' 连接到本地 MySQL 服务器 (2)
Doing this returns nothing
这样做没有任何回报
[root@ip-10-229-65-166 mysqld]# find -name mysql*
[root@ip-10-229-65-166 mysqld]# /etc/init.d/mysql stop -bash: /etc/init.d/mysql: No such file or directory
[root@ip-10-229-65-173 tpdatabase-1.8.0.28356]# mysql_config |grep -- --socket
--socket [/var/lib/mysql/mysql.sock]
[root@ip-10-229-65-166 mysqld]# find -name mysql*
[root@ip-10-229-65-166 mysqld]# /etc/init.d/mysql stop -bash: /etc/init.d/mysql: 没有那个文件或目录
[root@ip-10-229-65-173 tpdatabase-1.8.0.28356]# mysql_config |grep -- --socket
--socket [/var/lib/mysql/mysql.sock]
Maybe a permissions problem?
也许是权限问题?
I do have mysql installed using yum install mysql
我确实使用yum install mysql 安装了 mysql
I'm running CentOS 5.4 on a Amazon EC2 Cloud Instance
我在 Amazon EC2 云实例上运行 CentOS 5.4
回答by Noufal Ibrahim
mysql might have been packaged separately as client and server. Check your package repositories to make sure that the server has been installed. The mysql
package might only be the client. Check if there's a package called mysql-server
or something similar. Check the list of files installed by the mysql
package to see if it actually installs the server.
mysql 可能已单独打包为客户端和服务器。检查您的软件包存储库以确保已安装服务器。该mysql
包可能只是客户端。检查是否有一个包被调用mysql-server
或类似的东西。检查mysql
包安装的文件列表,看看它是否真的安装了服务器。
If the files are not even there, it's not a permissions problem. Also, you're running as root.
如果文件甚至不存在,则不是权限问题。此外,您以 root 身份运行。
回答by Andreas
just search for mysqld, this is the server daemon:
只需搜索 mysqld,这是服务器守护进程:
find / | grep mysqld
If you found it, the server package may be correctly installed but without initd scripts. For testing, you may start the mysql server by hand executing the above file.
如果您找到它,则服务器包可能已正确安装,但没有 initd 脚本。为了进行测试,您可以手动执行上述文件来启动 mysql 服务器。
回答by Alicia Casuso
You need to install the server package:
您需要安装服务器包:
sudo yum install mysql-server
After installation, you have to start the service:
安装后,您必须启动该服务:
sudo service mysqld start
回答by Knightly Oxford
We faced a similar problem in my office setup with the same OS. The actual thing that was happening was low space on the server. It is quite strange, but i believe if the server gets full the files cannot be loaded or of some other resort. Please check to be sure the space on the server is enough else you have to try removing the installed mysql and reinstall. Best of luck.
我们在使用相同操作系统的办公室设置中遇到了类似的问题。实际发生的事情是服务器上的空间不足。这很奇怪,但我相信如果服务器已满,则无法加载文件或其他方式。请检查以确保服务器上的空间足够,否则您必须尝试删除已安装的 mysql 并重新安装。祝你好运。
回答by Muhammad Asif
Before hitting mysql on command prompt make sure your correct my.cnf configuration file
is in placed and set the permission of etc folder as
在命令提示符下点击 mysql 之前,请确保您正确my.cnf configuration file
放置并将 etc 文件夹的权限设置为
chmod -R 777
chmod -R 777
etc folder as below list to avoid
etc 文件夹如下列表以避免
error MySQL - ERROR 2002 (HY000): e.g /etc/my.cnf, /etc/mysql/my.cnf, $MYSQL_HOME/my.cnf [datadir]/my.cnf ~/.my.cnf
错误 MySQL - 错误 2002 (HY000):例如 /etc/my.cnf、/etc/mysql/my.cnf、$MYSQL_HOME/my.cnf [datadir]/my.cnf ~/.my.cnf
回答by Indharajith
rm -rvf /var/lib/mysql/ib_logfile*
touch /var/lib/mysql/mysql.sock
touch /var/lib/mysql/mysql.pid
chown -R mysql:mysql /var/lib/mysql
systemctl restart mysql
try this and check the permission of both /var/lib/mysql/mysql.sock and /tmp
试试这个并检查 /var/lib/mysql/mysql.sock 和 /tmp 的权限