mysql无法启动 报错[ERROR] Can‘t open the mysql.plugin table. Please run mysql_upgrade to create it.

 在安装mysql 5.7的时候,安装成功了,但是无法启动,出现了报错:

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.

查看日志 cat /var/log/mysqld.log 看到错误:[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

cat /var/log/mysqld.log

mysqld: Table 'mysql.plugin' doesn't exist
2021-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: 3306
2021-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_pool
2021-04-27T08:55:46.472624Z 0 [Note] InnoDB: Buffer pool(s) load completed at 210427 16:55:46
2021-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 exist
2021-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 没有报错。花了六个小时终于解决问题。从上面报错可以看出,Mysql初始化出了问题。执行以下命令:

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

systemctl restart mysqld
systemctl status mysqld

这次竟然没有报错,问题解决了,Mysql顺利启动。

MySQL第一次启动后会创建超级管理员账号root@localhost初始密码存储在日志文件中

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

然后就可以使用初始密码登录MySQL,进行修改密码操作。

mysql -uroot -p

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

如果密码太简单,会报错:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements。解决方法如下:

  1. 使用复杂密码,MySQL默认的密码策略是要包含数字、字母及特殊字符;
  2. 如果只是测试用,不想用那么复杂的密码,可以修改默认策略,即validate_password_policy(以及validate_password_length等相关参数),使其支持简单密码的设定,具体方法可以自行百度;
  3. 修改配置文件/etc/my.cnf,添加validate_password=OFF,保存并重启MySQL
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)

密码改好后,执行 sudo systemctl restart mysqld 重启MySQL。

最后使用Navicat远程连接 MySQL的时候出现了报错:1130, "Host 'xxxx' is not allowed to connect to this MySQL server",

参考这篇博客解决了问题https://blog.csdn.net/h985161183/article/details/82218710

 

安装MySQL方法参考资料:https://juejin.cn/post/6844903870053761037

评论 1 您还未登录,请先 登录 后发表或查看评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页

打赏作者

weixin_42467709

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值