1, 问题描述
今天使用 MySQL 新建了一个用户, 此处假设为 test 用户, 用来作为某安装软件的配置用户 (会新建大量的表及视图)
MySQL> create user 'test'@'%' identified by '123456';
并将 MySQL 数据库授权给 test
MySQL> grant select,delete,update,create,drop on MySQL.* to [email protected]"%" identified by "123456";
以上均使用 root 用户执行
在软件中配置 jdbc 连接时, 报错如题: access denied for user 'test'@'%' to database 'mysql'.
2, 问题分析
考虑是权限不足的问题被拒绝访问, 查看了一些网上的回答, 测试如下方法可行
3, 解决方案
查看 user 表中 root 用户及 test 用户的权限对比
MySQL> select Grant_priv,Super_priv from MySQL.user where user in ('root','test');
发现 root 用户这两个 value 都是'Y', 而 test 用户都是'N'
将 test 用户这两个 value 都更新为'Y'
MySQL> update MySQL.user set Grant_priv='Y',Super_priv='Y' where user = 'test' and host = '%';
而后重启 MySQL 服务即可
来源: http://www.bubuko.com/infodetail-3090004.html