mysql ERROR 1045 (28000)

现象:
[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。
不然会同我一样拍错半天无头绪。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值