mysql ERROR 1045 (28000)

来源:互联网 发布:淘宝号为什么会被监控 编辑:程序博客网 时间:2024/06/15 23:10
现象:[root@test-1-dns1 ~]# mysql -utest -ptest -hxxx -P3309Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 140Server version: 5.7.12-log Source distributionType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> use test;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> 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。不然会同我一样拍错半天无头绪。

1 0