mysql Host 'XXX' is not allowed to connect to this MySQL server 解决方案

在 Windows 主机中点击开始菜单,运行,输入“cmd”,进入控制台,而后cd 进入MySQL 的 bin 目录下(能够不用进入bin目录本在在这里已经实验),而后输入下面的命令。
        > MySQL -uroot -p123456                 (123456 为 root 用户的密码。)mysql

如何开启MySQL的远程账号-2)建立远程登录用户并受权
        > grant all PRIVILEGES on *.* to root@'192.168.1.115'  identified by '123456';sql

上面的语句表示将数据库的全部权限受权给 root 这个用户,容许 root 用户在 192.168.1.115 这个 IP 进行远程登录,并设置 root 用户的密码为 123456 。数据库

固然也可单独给用户权限以下:ide

1,设置访问单个数据库权限spa

  mysql>grant all privileges on test.* to 'root'@'%';.net

2.设置访问所有数据库权限get

   mysql>grant all privileges on *.* to 'root'@'%';cmd

    说明:设置用户名为root,密码为空,可访问全部数据库*it

 

3.设置指定用户名访问权限class

  mysql>grant all privileges on *.* to 'testyonghu'@'%';

4.设置密码访问权限

  mysql>grant all privileges on *.* to 'zhangsan'@'%' IDENTIFIED BY '123456';

5.设置指定可访问主机权限

 grant all privileges on *.* to 'lisi'@'192.168.1.115';

 

====================================================================

全部的设置完以后,还须要  执行 mysql>  FLUSH PRIVILEGES;

而后退出mysql生效

相关文章
相关标签/搜索