验证码: 看不清楚,换一张 查询 注册会员,免验证
  • {{ basic.site_slogan }}
  • 打开微信扫一扫,
    您还可以在这里找到我们哟

    关注我们

MySQL怎么开启用户远程登录权限

阅读:1052 来源:乙速云 作者:代码code

MySQL怎么开启用户远程登录权限

MySQL开启用户远程登录权限

当在Docker中创建一个Mysql的容器后,需要使用工具如:navicate来连接容器内的MySQL服务,但是

提示Access denied for user 'root'@ 'x.x.x.x' (using password: YES) 错误,用命令进入容器确认密码没有问题,那么就可能是没有开发远程权限。

第一步:选中mysql数据库

use mysql;

第二步:修改库中user表中,user用户的host=%(任意连接)

update user set host='%' where user ='root';

第三步:重新加载权限表

flush privileges;

第四步:给root用户赋予远程连接权限

grant all privileges on *.* to 'root'@'%' with grant option;
# 赋予权限并修改密码
alter user 'root'@'%' identified with mysql_native_password by '123456';

开放MySQL的远程访问权限

1.使用 mysql -u root -p 连接到本地MySQL服务

2.登录后使用 use mysql;

3.使用 grant all privileges on . to ‘root’@‘%’ identified by ‘123456’ with grant option; 赋予远程登录用户权限(使用root账号和密码123456,从任何主机连接到mysql服务器),刷新权限 FLUSH PRIVILEGES;

4.使用 select user,host from user 查看系统用户

5.使用 vim /etc/mysql/mysql.conf.d/mysqld.cnf 修改bind-address的访问网址,将 bind-address=127.0.0.1 改成 bind-address=0.0.0.0

6.开放端口 3306(这是MySQL的默认端口) 

分享到:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: hlamps#outlook.com (#换成@)。
相关文章
{{ v.title }}
{{ v.description||(cleanHtml(v.content)).substr(0,100)+'···' }}
你可能感兴趣
推荐阅读 更多>