缺少 /var/lib/mysql/mysql.sock 文件

发布于 2024-11-01 19:02:26 字数 692 浏览 1 评论 0原文

我正在尝试访问 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]# mysql

ERROR 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

温柔戏命师 2024-11-08 19:02:26

您需要安装服务器包:

sudo yum install mysql-server

安装后,您必须启动服务:

sudo service mysqld start

You need to install the server package:

sudo yum install mysql-server

After installation, you have to start the service:

sudo service mysqld start
紫﹏色ふ单纯 2024-11-08 19:02:26
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

尝试这个并检查 /var/lib/mysql/mysql.sock 和 /tmp 的权限

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

愛上了 2024-11-08 19:02:26

我们在使用相同操作系统的办公室设置中遇到了类似的问题。实际发生的事情是服务器空间不足。这很奇怪,但我相信如果服务器已满,则无法加载文件或无法加载其他文件。请检查确保服务器上的空间足够,否则您必须尝试删除已安装的 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.

触ぅ动初心 2024-11-08 19:02:26

只需搜索 mysqld,这是服务器守护进程:

find / | grep mysqld

如果找到它,则服务器软件包可能已正确安装,但没有 initd 脚本。为了进行测试,您可以手动执行上述文件来启动 mysql 服务器。

just search for mysqld, this is the server daemon:

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.

深府石板幽径 2024-11-08 19:02:26

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 called mysql-server or something similar. Check the list of files installed by the mysql 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.

复古式 2024-11-08 19:02:26

我最近在 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.

简单爱 2024-11-08 19:02:26

确保您有权访问 /var/lib/mysql/mysql.sock 文件。如果仍然出现错误,请创建默认的 my.cnf 文件

[client]
socket = /path/to/mysql/data/mysql.sock
[mysqld]
server-id = 2
socket = /path/to/mysql/data/mysql.sock
port = 4000 #any port you wish
basedir = /path/to/mysql
datadir = /path/to/mysql/data

并再次初始化数据库。确保在初始化时给出 --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

[client]
socket = /path/to/mysql/data/mysql.sock
[mysqld]
server-id = 2
socket = /path/to/mysql/data/mysql.sock
port = 4000 #any port you wish
basedir = /path/to/mysql
datadir = /path/to/mysql/data

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.

风月客 2024-11-08 19:02:26

在命令提示符下点击 mysql 之前,请确保已放置正确的 my.cnf 配置文件,并将 etc 文件夹的权限设置为

chmod -R 777

etc 文件夹,如下所示避免

错误 MySQL - 错误 2002 (HY000):
例如 /etc/my.cnf、/etc/mysql/my.cnf、$MYSQL_HOME/my.cnf [datadir]/my.cnf ~/.my.cnf

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

chmod -R 777

etc folder as below list to avoid

error MySQL - ERROR 2002 (HY000):
e.g /etc/my.cnf, /etc/mysql/my.cnf, $MYSQL_HOME/my.cnf [datadir]/my.cnf ~/.my.cnf

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文