例子:
允许myuser使用mypassword从任何主机连接到mysql服务器。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;FLUSH PRIVILEGES;
允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
允许用户myuser从ip为192.168.1.6的主机连接到mysq服务器的dk数据库,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
问题:配置完之后还是不能访问。
原因:原因 - Windows 防火墙 在windows cmd上使用管理员权限运行下面的命令即可:
netsh advfirewall firewall add rule name="MySQL Server" action=allow protocol=TCP dir=in localport=3306