目录 1.修改权限 2.赋权 使用Navicat远程连接,Docker中的Mysql5.7版本中新建数据库报错: 1044 -Access denied for user 'root'@'%' to database 远程连接工具可以
目录
使用Navicat远程连接,Docker中的Mysql5.7版本中新建数据库报错:
1044 -Access denied for user 'root'@'%' to database
远程连接工具可以成功连接,docker中数据库容器,但是只会显示自动生成的数据库,其他的必要数据库无法显示出来:
报错是因为root没有权限的原因,找到一下两种解决办法:
mysql> SELECT host,user,Grant_priv,Super_priv FROM mysql.user;+-----------+---------------+------------+------------+| host | user | Grant_priv | Super_priv |+-----------+---------------+------------+------------+| localhost | root | Y | Y || localhost | mysql.session | N | Y || localhost | mysql.sys | N | N || % | root | Y | Y || localhost | mysqladmin | Y | Y |+-----------+---------------+------------+------------+5 rows in set (0.00 sec)mysql> UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';Query OK, 0 rows affected (0.00 sec)Rows matched: 2 Changed: 0 Warnings: 0mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.00 sec)mysql> exitBye
查询用户表看root用户权限
SELECT host,user,Grant_priv,Super_priv FROM mysql.user;
修改权限,命令如下:
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';FLUSH PRIVILEGES;
mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> update user set host='%' where user='root';ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';Query OK, 0 rows affected (0.00 sec)mysql> exitBye
mysql赋权操作,总结命令如下:
use mysql;update user set host='%' where user='root';GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
两个方法都可以试试,我遇到这个问题时把两个方法用了一遍,中间忘记重启容器了,所以不知道是哪个方法起到的作用,所以记得重启一下MySQL容器
命令:
重启docker容器
systemctl restart docker
重启MySQL容器
docker restart mysql
来源地址:https://blog.csdn.net/qq_54928486/article/details/125666293
--结束END--
本文标题: mysql报错:1044 -Access denied for user ‘root‘@‘%‘ to database
本文链接: https://lsjlt.com/news/387310.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0