数据库授权用户,允许192.168.100.0/24网段可以连接mysql
1. 访问数据库
# 主机测试
[root@node1 ~]# mysql -uroot -p
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| hellodb |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
2. 创建用户
# 创建用户赋权刷新
mysql> CREATE USER feifa @'192.168.100.%' IDENTIFIED BY 'PASSWORD';
mysql> FLUSH PRIVILEGES;
3. 登录测试
# 使用其他机器登录测试,发现能登陆但是数据库未授权
[root@node3 ~]# hostname -I
192.168.100.132
[root@node3 ~]# yum -y install mysql
[root@node3 ~]# mysql -ufeifa -pPASSWORD -h192.168.100.128
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
4.赋权访问数据库
# 回到node1上面对feifa用户进行赋权
mysql> GRANT ALL PRIVILEGES ON hellodb.* TO 'feifa' @'192.168.100.%';
mysql> FLUSH PRIVILEGES;
5.连接测试
# 在node3上查看效果
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| hellodb |
| information_schema |
+--------------------+
标签:+--------------------+,网段,数据库,192.168,mysql,node3,schema
From: https://www.cnblogs.com/feifa/p/16953283.html