场景:mysql8.0的数据库执行show databases 报错ERROR 1449 (HY000)The user specified as a definer (‘mysql.infoschema’@‘localhost’) does not exist
1.演示错误:
mysql [localhost:8024] {msandbox} ((none)) > delete from mysql.user where user=‘mysql.infoschema’;
Query OK, 1 row affected (0.01 sec)
mysql [localhost:8024] {msandbox} ((none)) > flush privilges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘privilges’ at line 1
mysql [localhost:8024] {msandbox} ((none)) > flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql [localhost:8024] {msandbox} ((none)) > select user,host from mysql.user;
±--------------±----------+
| user | host |
±--------------±----------+
| R_CUSTOM | % |
| R_DO_IT_ALL | % |
| R_READ_ONLY | % |
| R_READ_WRITE | % |
| R_REPLICATION | % |
| msandbox | 127.% |
| msandbox_ro | 127.% |
| msandbox_rw | 127.% |
| rsandbox | 127.% |
| msandbox | localhost |
| msandbox_ro | localhost |
| msandbox_rw | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
±--------------±----------+
15 rows in set (0.00 sec)
mysql [localhost:8024] {msandbox} ((none)) > show databases;
ERROR 1449 (HY000): The user specified as a definer (‘mysql.infoschema’@‘localhost’) does not exist
mysql [localhost:8024] {msandbox} ((none)) > exit
因是手动删除了系统用户,一种方法是再创建用户,授权可以解决。
另一种是重新升级一下数据字典。
2.升级数据字典


3.小结
数据字典不一致的,有可能是mysql5.7升级到8.0未完成。8.0会自动升级数据字典,不像原来版本,要手动执行mysql_upgrade.




