博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql登陆启动报错 ERROR 2002 (HY000) 解决方法
阅读量:5896 次
发布时间:2019-06-19

本文共 2401 字,大约阅读时间需要 8 分钟。

报错信息

登陆数据库报错:`

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory")`


重启服务报错:Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.


查看服务状态信息:`systemctl status mariadb.service

● mariadb.service - MariaDB 10.1 database server

Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2019-04-15 17:16:38 UTC; 4s ago
Process: 2864 ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=1/FAILURE)
Process: 2841 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)

Apr 15 17:16:37 xiandian systemd[1]: Starting MariaDB 10.1 database server...

Apr 15 17:16:38 xiandian mysql-prepare-db-dir[2864]: Database MariaDB is not initialized, but the directory /var/lib/mysql is not empty...e done.
Apr 15 17:16:38 xiandian mysql-prepare-db-dir[2864]: Make sure the /var/lib/mysql is empty before running mysql-prepare-db-dir.
Apr 15 17:16:38 xiandian systemd[1]: mariadb.service: control process exited, code=exited status=1
Apr 15 17:16:38 xiandian systemd[1]: Failed to start MariaDB 10.1 database server.
Apr 15 17:16:38 xiandian systemd[1]: Unit mariadb.service entered failed state.
Apr 15 17:16:38 xiandian systemd[1]: mariadb.service failed.
Hint: Some lines were ellipsized, use -l to show in full.`

重启服务日志报错信息:`Apr 15 17:16:21 xiandian mysql-prepare-db-dir: Database MariaDB is not initialized, but the directory /var/lib/mysql is not empty, so initialization cannot be done.

Apr 15 17:16:21 mysql-prepare-db-dir: Make sure the /var/lib/mysql is empty before running mysql-prepare-db-dir.

Apr 15 17:16:21 systemd: mariadb.service: control process exited, code=exited status=1
Apr 15 17:16:21 systemd: Failed to start MariaDB 10.1 database server.
Apr 15 17:16:21 systemd: Unit mariadb.service entered failed state.
Apr 15 17:16:21 systemd: mariadb.service failed.`


可以看到报错信息中提示数据库未初始化,但/var/lib/mysql不为空,所以无法进行初始化。


去看一下这个目录权限

ll /var/lib/ d---------. 11 mysql      mysql      4096 May  4  2018 mysql

mysql权限为0,导致启动文件sock文件无法写入进去

重启赋予目录权限为755
chmod 755 /var/lib/mysql/
然后再重启一下mysql服务
systemctl restart mariadb.service
ps -e | grep -i mysql
3191 ? 00:00:02 mysqld
正常启动

转载于:https://blog.51cto.com/9103824/2378808

你可能感兴趣的文章
yum锁定强行解锁
查看>>
静态路由
查看>>
Spark官方文档: Spark Configuration(Spark配置)
查看>>
yum 6.8 nginx php-fpm
查看>>
我的友情链接
查看>>
网络安全基础知识之侦察与工具
查看>>
ANDROID使用PROGUARD实现代码混淆
查看>>
字符编码问题
查看>>
IPv4协议及VLSM可变长子网划分和CIDR无类域间路由
查看>>
组建创业团队时不可或缺的几类人
查看>>
LNMP(Linux+Nginx+Mysql+PHP)的搭建
查看>>
我的友情链接
查看>>
检测bash是否需要升级
查看>>
Exchange 2010,删除系统默认地址列表后, OWA 通讯簿失败问题解决办法
查看>>
Java NIO系列教程(四) Scatter/Gather
查看>>
Cisco交换机3750密码破解(一)
查看>>
dubbo服务只订阅(开发调试)
查看>>
索引优化策略面试题(多列/复合索引)
查看>>
VMware VIX API使用教程
查看>>
软件包安装(yum配置)
查看>>