MySQL 使用 show tables 时出现 ERROR 1449 (HY000) 问题

一、问题出现

在安装完 MySQL 后,使用 SHOW TABLES 时,发现一直出现 ERROR 1449 (HY000):The user specified as a definer (‘mysql.infoschema‘@’localhost’) does not exist 。具体去网上搜索,给的答案都是用 mysql_upgrade ,事实上 mysql_upgrade 功能在 mysql8.0 之后版本已经停用了。在经过多方查找后,找到如下解决方案。

mysql> use goblog
Database changed
mysql> show tables;
ERROR 1449 (HY000): The user specified as a definer ('mysql.infoschema'@'localhost') does not exist

二、解决方案

总体办法就是给 mysql.infoschema 用户添加权限。
MySQL8.0 之后,不支持使用 grant 时隐式地创建用户,必须先创建用户,再授权。代码如下:

mysql> create user 'mysql.infoschema'@'%' identified by '密码';
Query OK, 0 rows affected (0.01 sec)
mysql> create user 'mysql.infoschema'@'%' identified by '密码';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on *.* to 'mysql.infoschema'@'%';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

再使用 show tables ,就能出现结果了。

mysql> show tables;
+------------------+
| Tables_in_goblog |
+------------------+
| articles         |
+------------------+
1 row in set (0.01 sec)
本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!