无法通过socket' /var/lib/mysql/mysql.sock&#39连接到本地MySQL服务器; (2)。 / var / lib / mysql /中不存在mysql.sock

时间:2016-02-12 15:14:05

标签: mysql amazon-ec2 mysql.sock

Magento显示"处理您的请求时出现错误"

当试图命令" sudo service mysqld restart"但未能开始

然后看日志显示我" SQLSTATE [HY000] [2002]没有这样的文件或目录"

我在Google,stackoverflow,magento stackoverflow网站上搜索很少,最后得到的东西可能是

命令后#34; mysqld -u root -p status"

显示' mysqladmin:在' localhost'连接到服务器失败 错误:'无法通过socket' /var/lib/mysql/mysql.sock'连接到本地MySQL服务器; (2)' 检查mysqld是否正在运行以及socket:' /var/lib/mysql/mysql.sock'存在!

我发现我在/ var / lib / mysql /中没有mysql.sock现在应该怎么做。我不是新手专家。不幸的是,我给了ec2实例中所有目录的777权限,在这个问题的一段时间后,我看到了我的网站"处理您的请求时出错。出于ec2安全原因,我无法使用ftp或ssh访问实例。所以我不得不创建新实例将此EBS提供给新实例,在更改权限后我可以访问我的实例

请查看我的my.cnf文件。我看到有些东西可以提供帮助

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

这是mysqld.log

/usr/libexec/mysql55/mysqld: Can't create/write to file '/tmp/ibmCz4dv'     (Errcode: 13)
160212 18:29:37  InnoDB: Error: unable to create temporary file; errno: 13
160212 18:29:37 [ERROR] Plugin 'InnoDB' init function returned error.
160212 18:29:37 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE   failed.
160212 18:29:37 [ERROR] Unknown/unsupported storage engine: InnoDB
160212 18:29:37 [ERROR] Aborting
160212 18:29:37 [Note] /usr/libexec/mysql55/mysqld: Shutdown complete
160212 18:29:37 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

775到/ tmp和现在的mysqld.log

775到/ tmp和mysqld.log

/usr/libexec/mysql55/mysqld: Can't create/write to file '/tmp/ibLzshr1' (Errcode: 13)
160213  9:08:59  InnoDB: Error: unable to create temporary file; errno: 13
160213  9:08:59 [ERROR] Plugin 'InnoDB' init function returned error.
160213  9:08:59 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
160213  9:08:59 [ERROR] Unknown/unsupported storage engine: InnoDB
160213  9:08:59 [ERROR] Aborting

160213  9:08:59 [Note] /usr/libexec/mysql55/mysqld: Shutdown complete

160213 09:08:59 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

请帮我把它整理出来

2 个答案:

答案 0 :(得分:0)

mysql用户显然无权根据

在/ tmp中创建文件
/usr/libexec/mysql55/mysqld: Can't create/write to file '/tmp/ibmCz4dv'     (Errcode: 13)

检查/ tmp上的访问权限,应为777。 BTW sys“errno 13”是“Permission denied”

根据这一点,服务器停止并且不创建任何套接字,然后导致连接错误。

答案 1 :(得分:0)

我要感谢@ Axel Amthor。最后我给了/ tmp文件777并重新启动了mysqld ..和Boom

网站重新开始行动。对不起,我不能给Upvote,因为我没有声誉15 :(