iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >systemctl status mysqld.service或者systemctl start mysqld 启动失败的解决办法
  • 867
分享到

systemctl status mysqld.service或者systemctl start mysqld 启动失败的解决办法

mysql数据库服务器 2023-09-08 09:09:27 867人浏览 安东尼
摘要

报错过程: Mysql需要启动,执行一下命令启动mysql: systemctl start mysqld.service 结果出现如下提示 Job for mysqld.service faile

报错过程:

Mysql需要启动,执行一下命令启动mysql

systemctl start  mysqld.service

结果出现如下提示

Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

在这里给大家一个提示,因为每个人的报错原因不同,我们需要去查看mysql的日志

vi /var/log/mysqld.log

如果mysql日志太多,可以通过dG将mysql的日志全部删除,之后再执行启动musql的命令

systemctl start  mysqld.servicevi /var/log/mysqld.log  // 查看报错日志

找到日志中出现error的地方,根据具体问题搜索具体博客的解决办法

我的日志文件中报错大致如下。

mysqld: Table 'mysql.plugin' doesn't exist2021-04-27T08:55:46.468329Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.2021-04-27T08:55:46.468825Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.2021-04-27T08:55:46.470106Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.2021-04-27T08:55:46.470119Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.2021-04-27T08:55:46.471231Z 0 [Warning] CA certificate ca.pem is self signed.2021-04-27T08:55:46.471281Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.2021-04-27T08:55:46.472264Z 0 [Note] Server hostname (bind-address): '*'; port: 33062021-04-27T08:55:46.472311Z 0 [Note] IPv6 is available.2021-04-27T08:55:46.472322Z 0 [Note]   - '::' resolves to '::';2021-04-27T08:55:46.472345Z 0 [Note] Server Socket created on IP: '::'.2021-04-27T08:55:46.472543Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool2021-04-27T08:55:46.472624Z 0 [Note] InnoDB: Buffer pool(s) load completed at 210427 16:55:462021-04-27T08:55:46.476676Z 0 [Warning] Failed to open optimizer cost constant tables 2021-04-27T08:55:46.476791Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist2021-04-27T08:55:46.476806Z 0 [ERROR] Fatal error: Failed to initialize ACL/grant/time zones structures or failed to remove temporary table files.2021-04-27T08:55:46.476836Z 0 [ERROR] Aborting

从上面的报错可以看出,Mysql初始化出了问题。执行以下命令:

cd /   rm -rf /var/lib/mysql/*mysqld --initialize --user=mysql --datadir=/var/lib/mysql

之后重启mysql 并查看mysql的状态

systemctl restart mysqldsystemctl status mysqld

在这里插入图片描述
MySQL第一次启动后会创建超级管理员账号root@localhost,初始密码存储在日志文件中,查看密码

sudo grep 'temporary passWord' /var/log/mysqld.log

在这里插入图片描述
可以看到,我的初始密码为 iFqxsrSB&10o,准备登陆

mysql -uroot -p 

在这里插入图片描述
登陆成功后,修改密码,并开启访问权限

set global validate_password_length=4;      # 设置密码长度最低位数,适用于老版本set global validate_password_policy=LOW;# 设置密码安全等级低,便于密码可以修改成root,适用于老版本set password=password('root');# 设置密码为root# 开启访问权限grant all on *.* to 'root'@'%' identified by 'root';flush privileges;

在这里插入图片描述
之后退出mysql,再次通过root密码登录mysql

mysql -uroot -proot

在这里插入图片描述
登陆成功!

来源地址:https://blog.csdn.net/qq_43316970/article/details/127440564

您可能感兴趣的文档:

--结束END--

本文标题: systemctl status mysqld.service或者systemctl start mysqld 启动失败的解决办法

本文链接: https://www.lsjlt.com/news/399696.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作