我正在尝试在Docker中启动mysql-client,但由于用户错误我被拒绝访问 [英] I am trying to start mysql-client in Docker but i get access denied for user error

查看:48
本文介绍了我正在尝试在Docker中启动mysql-client,但由于用户错误我被拒绝访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将MySQL Client连接到docker.我可以在MySQL 8.0命令行客户端上很好地连接,但是当我尝试从docker连接到它时,出现此错误:

I am trying to connect MySQL Client to docker. I can connect just fine on the MySQL 8.0 Command Line Client, but when I try to connect to it from docker I get this error:

C:\ Users \ Bolin> docker exec -it mysql mysql -u根-p输入密码:错误1045(28000):用户'root'@'localhost'的访问被拒绝(使用密码:是)

C:\Users\Bolin>docker exec -it mysql mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

我在开窗机上,正在尝试按照本教程进行操作 https://phoenixnap.com/kb/mysql-docker-container

I am on a window machine and I am trying to follow this tutorial https://phoenixnap.com/kb/mysql-docker-container

推荐答案

hmm,问题似乎出在数据库表的特权用户身上,尝试在名为root的数据库中创建特权用户.之后请再次检查

hmm, looks like the issue is with privilege user for the database table, Try to create a privileged user in your database named root. After that please check again

==========================================================================================在您的数据库中尝试以下查询:

========================================================================================== try these queries in your databse:

INSERT INTO mysql.user (Host, User, Password) VALUES ('%', 'root', password('YOURPASSWORD'));
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;

如果上面的代码不起作用,请尝试第二个

if the above code doesn't work try with the second

$mysql -u root mysql
$mysql> UPDATE user SET Password=PASSWORD('my_password') where USER='root';
$mysql> FLUSH PRIVILEGES;

这篇关于我正在尝试在Docker中启动mysql-client,但由于用户错误我被拒绝访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆