开启MySQL远程访问权限 允许远程连接

系统环境:Linux CentOS  数据库版本:MySQL5.7

1、登陆mysql数据库

mysql -h ip地址 -u 用户名 -p 密码

 

2、增加远程连接权限 

  •  

    use mysql;

  •  

    grant all privileges on *.* to 远程连接用户名@’%’ identified by “远程连接密码”;

  •  

    flush privileges;

  • 3.修改MySQL配置文件 

    vim /etc/mysql/mysql.conf.d/mysqld.cnf

    注释掉bind-address这行 

    4.重启数据库

  •  

    service mysql restart

  •  

    或(选择一个可以运行的命令进行尝试)

  •  

    systemctl restart mysqld

  • 5.如果想要修改数据密码怎么办呢?可以使用以下命令进行操作

    #进入数据库
    use mysql;
     
    #修改密码
    update mysql.user set authentication_string=password(‘new password’) where user=’root’;
     
    #刷新使其生效
    flush privileges;

    0

    评论0

    请先
    显示验证码
    没有账号?注册  忘记密码?