解决 The user specified as a definer ('mysql.infoschema'@'localhost') does not exist

/ linux / 10 条评论 / 8067浏览
忙于工作,由于升级Ubuntu20导致mysql由5.7升级到mysql 8.0.22(8.0.16以上),出现登录等使用问题。

The user specified as a definer ('mysql.infoschema'@'localhost') does not exist

经过我多放查考,试遍了各种方法。

吐槽一下(特么居然还有人建议卸载 删mysql文件夹的文章,删库跑路咋的????删库跑路的方案,给一个链接 以后看到这个人 就弄他

mysql_upgrade -u root -p

无效。mysql放弃了mysql_upgrade。

请输入图片描述

之后尝试mysql8.0.16以后推荐的方法

 /usr/sbin/mysqld --upgrade=NONE

请输入图片描述

终于自己解决了这个问题。

查看错误日志

 tail -f /var/log/mysql/error.log

再次执行

 /usr/sbin/mysqld --upgrade=NONE

看到

请输入图片描述

> Found invalid password for user: 'mysql.infoschema@localhost'; Ignoring user

发现了这么个东西

之后经过各种mysql官方文档,得知mysql换了加密算法。

 sudo mysql 

进入mysql (进入不了请看这篇文章初始化mysql

 use mysql;
 select Host,user,authentication_string,plugin from user;

请输入图片描述

发现了这个!!! 在我初始化root用户的时候,被无良博主坑了,把所有用户的plugin都换成了mysql5.7的插件“mysql_native_password”

而最新的mysql8.0的密码插件是caching_sha2_password

根据观察$A$005$是caching_sha2_password这个插件加密出来的密码的头段

更新两条数据的plugin

 update user set plugin = 'caching_sha2_password' where user='mysql.sys' or user='mysql.infoschema';
 exit

重启mysql

 service mysql restart

 ***workbench来一波,完美解决!***

请输入图片描述

补充内容

没想到我这个小小的博客也有人留言问我。不适用于所有的,我特意去看了下mysql开发者Zone,发现了还有一钟导致的问题。

The grant tables in the mysql system database are now InnoDB (transactional) tables. Previously, these were MyISAM (nontransactional) tables. This change applies to these tables: user, db, tables_priv, columns_priv, procs_priv, proxies_priv.

If you upgrade to this MySQL release from an earlier version, you must run mysql_upgrade (and restart the server) to incorporate these changes into the mysql system database.

Note If MySQL is upgraded from an older version but the grant tables have not been upgraded from MyISAM to InnoDB, the server considers them read only and account-management statements produce an error.

大致意思是MySQL的系统表以前的是MyISAM的,8.0往后是innodb了,如果你是从老版本升级上来的,但是这些grant表(咋翻译呢,就是可以grant的表,什么用户,角色这种),并没能从MyISAM升级到innodb,服务器就会人为是只读,账户管理的时候就会报错。

你就直接把表alter成innodb就ok

  1. 终于解决问题了,谢谢

  2. 牛阿牛阿!

  3. 找了很多解决办法,这个完美解决,写了博主

  4. T T实在太感谢了!!!就是caching_sha2_password的问题,感谢感谢!!

  5. 可以可以 大佬厉害了 感谢感谢

  6. 牛逼啊大佬