现象:
[root@test-1-dns1 ~]# mysql -utest -ptest -hxxx -P3309
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 140
Server version: 5.7.12-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from test limit 5;
ERROR 1045 (28000): Access denied for user 'test'@'%' (using password: YES)
1.检查数据库用户权限
mysql> show grants for 'test'@'%';
+----------------------------------------------+
| Grants for test@% |
+----------------------------------------------+
| GRANT USAGE ON *.* TO 'test'@'%' |
| GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'%' |
+----------------------------------------------+
2 rows in set (0.00 sec)
到这里大家肯定疑惑了,我也疑惑了,为什么没有权限?
于是用最大权限的root去查询试试。
2.用root用户去查询
mysql> select * from test.test;
ERROR 1449 (HY000): The user specified as a definer ('zk'@'%') does not exist
到了这里就明白了,是我之前把这个zk用户删除了,由此造成无法访问。
最后还从开发哪里了解到这个是个视图,那就更理解错误原因了。
3.解决问题,两个思路
a.重新建立用户zk并赋予权限
b.重建视图即可。 --此时我选择的这种方式。
4.经验教训
由此得知mysql里面看着没用的用户也不能删除啊,至少得检查一下视图,触发器,表的difiner。
不然会同我一样拍错半天无头绪。
mysql ERROR 1045 (28000)
最新推荐文章于 2024-07-22 15:07:35 发布