MySQL开启远程访问权限

1、第一步登录数据库

[root@instance-u5vpjp1n ~]# mysql -uroot -p
2、进到mysql库

MariaDB [(none)]> use mysql;

3、查看权限情况

MariaDB [mysql]> select host,user,password from user;
MySQL开启远程访问权限_第1张图片
4、基于用户

MariaDB [mysql]> grant all privileges on *.* to root@'%'identified by '123456';

MariaDB [mysql]> flush privileges;

5、基于IP

MariaDB [mysql]> grant all privileges on *.* to 'root'@'192.168.0.4'identified by '123456' with grant option;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> flush privileges;

MySQL开启远程访问权限_第2张图片

 

你可能感兴趣的:(MySQL,数据库)