缺少 /var/lib/mysql/mysql.sock 文件
我正在尝试访问 mysql,当我运行 mysql 命令时,我得到以下信息。
[root@ip-10-229-65-166 tpdatabase-1.8.0.28356]#mysql
错误 2002 (HY000):无法连接到 通过socket本地MySQL服务器 '/var/lib/mysql/mysql.sock' (2)
这样做不会返回任何内容
[root@ip-10-229-65-166 mysqld]# 查找 -名称 mysql*
[root@ip-10-229-65-166 mysqld]# /etc/init.d/mysql 停止 -bash: /etc/init.d/mysql: 没有这样的文件或目录
[root@ip-10-229-65-173 tpdatabase-1.8.0.28356]# mysql_config |grep -- --socket
--套接字[/var/lib/mysql/mysql.sock]
也许是权限问题?
我确实使用 yum install mysql 安装了 mysql
我在 Amazon EC2 云实例上运行 CentOS 5.4
I'm trying to access mysql and when I run the mysql command, I get the following.
[root@ip-10-229-65-166
tpdatabase-1.8.0.28356]# mysqlERROR 2002 (HY000): Can't connect to
local MySQL server through socket
'/var/lib/mysql/mysql.sock' (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]
Maybe a permissions problem?
I do have mysql installed using yum install mysql
I'm running CentOS 5.4 on a Amazon EC2 Cloud Instance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
您需要安装服务器包:
安装后,您必须启动服务:
You need to install the server package:
After installation, you have to start the service:
尝试这个并检查 /var/lib/mysql/mysql.sock 和 /tmp 的权限
try this and check the permission of both /var/lib/mysql/mysql.sock and /tmp
我们在使用相同操作系统的办公室设置中遇到了类似的问题。实际发生的事情是服务器空间不足。这很奇怪,但我相信如果服务器已满,则无法加载文件或无法加载其他文件。请检查确保服务器上的空间足够,否则您必须尝试删除已安装的 mysql 并重新安装。祝你好运。
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.
只需搜索 mysqld,这是服务器守护进程:
如果找到它,则服务器软件包可能已正确安装,但没有 initd 脚本。为了进行测试,您可以手动执行上述文件来启动 mysql 服务器。
just search for mysqld, this is the server daemon:
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.
mysql 可能已分别打包为客户端和服务器。检查您的软件包存储库以确保服务器已安装。
mysql
包可能只是客户端。检查是否有名为mysql-server
的包或类似的包。检查mysql
包安装的文件列表,看看它是否真正安装了服务器。如果文件根本不存在,则不是权限问题。另外,您以 root 身份运行。
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 calledmysql-server
or something similar. Check the list of files installed by themysql
package to see if it actually installs the server.If the files are not even there, it's not a permissions problem. Also, you're running as root.
我最近在 Ubuntu 18.04 升级后遇到了这个问题。这里的解决方案解决了它https://serverfault.com/a/957723/439448。
I recently encountered this problem after an upgrade on Ubuntu 18.04. The solution here solved it https://serverfault.com/a/957723/439448.
确保您有权访问 /var/lib/mysql/mysql.sock 文件。如果仍然出现错误,请创建默认的 my.cnf 文件
并再次初始化数据库。确保在初始化时给出
--defaults-file=/path/to/mysql/my.cnf
。如果您收到错误消息,指出/path/to/mysql/data
中存在文件,请删除它们并重试。完成后,当您也运行 mysql 时,输入--defaults-file=/path/to/mysql/my.cnf
。应该有效。
Make sure you have privileges to access the /var/lib/mysql/mysql.sock file. And if you still get the error, create a default my.cnf file with
and initialize the database again. Make sure you give
--defaults-file=/path/to/mysql/my.cnf
when you initialize. If you get error saying files exist in/path/to/mysql/data
, remove them and try again. Once done, when you run mysql also, give--defaults-file=/path/to/mysql/my.cnf
.Should work.
在命令提示符下点击 mysql 之前,请确保已放置正确的
my.cnf 配置文件
,并将 etc 文件夹的权限设置为chmod -R 777
etc 文件夹,如下所示避免
Before hitting mysql on command prompt make sure your correct
my.cnf configuration file
is in placed and set the permission of etc folder aschmod -R 777
etc folder as below list to avoid