MySQL配置远程访问


配置远程访问mysql

mysql设置指定ip远程访问连接实例

授权用户root从任意主机连接到mysql服务器

use mysql;

GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘root’ WITH GRANT OPTION;

FLUSH PRIVILEGES;

或者

use mysql;

update user set host = ‘%’ where user = ‘root’;

授权用户root使用密码password从指定ip为61.139.22.32的主机连接到mysql服务器:

GRANT ALL PRIVILEGES ON . TO ‘root’@’61.139.22.32’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;

flush privileges;


GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.50.11' IDENTIFIED BY 'root' WITH GRANT OPTION;
flush privileges;
 

授权用户root使用密码password从指定ip段为61.139.22.%的主机连接到mysql服务器:

GRANT ALL PRIVILEGES ON . TO ‘root’@’61.139.22.%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;

flush privileges;

授权用户root使用密码password只能从本地的主机连接到mysql服务器:

GRANT ALL PRIVILEGES ON . TO ‘root’@’localhost’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;

flush privileges;

mysql 允许所有 ip 访问

mysql -uroot -proot
use mysql;
grant all privileges  on *.* to root@'%' identified by "root";
flush privileges;

指定 ip 及端口访问

mysql -uroot -p -h10.154.0.43 -P3341