標籤:mysql
/***** 查看使用者 *****/
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)
本文出自 “老炮兒” 部落格,請務必保留此出處http://joelemma.blog.51cto.com/11189330/1763068
Mysql使用者授權