/***** 查看用户 *****/
mysql> select User,Host from mysql.user;
+------+-----------+
| User | Host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| root | localhost |
+------+-----------+
3 rows in set (0.01 sec)
/***** 授权用户 *****/
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.11.80‘;
Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> select User,Host from mysql.user;
+------+-----------+
| User | Host |
+------+-----------+
| root | % |
| root | 127.0.0.1 |
| root | 192.168.* |
| root | ::1 |
| root | localhost |
+------+-----------+
5 rows in set (0.00 sec)
/***** 删除用户 *****/
mysql> drop USER ‘root‘@‘192.168.11.80‘;
Query OK, 0 rows affected (0.00 sec)
mysql> select User,Host from mysql.user;
+------+-----------+
| User | Host |
+------+-----------+
| root | % |
| root | 127.0.0.1 |
| root | ::1 |
| root | localhost |
+------+-----------+
4 rows in set (0.00 sec)
/***** 授权部分网段用户 *****/
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.%‘;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> select User,Host from mysql.user;
+------+-----------+
| User | Host |
+------+-----------+
| root | % |
| root | 127.0.0.1 |
| root | 192.168.% |
| root | ::1 |
| root | localhost |
+------+-----------+
5 rows in set (0.00 sec)
/***** 设置用户密码 *****/
mysql> SET PASSWORD FOR ‘root‘@‘192.168.%‘ = PASSWORD(‘123456‘);
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)