標籤:sage password select 伺服器 一個 sele show 指定 管理
-- 授權一個使用者(zhangsan)密碼123,可以對所有的庫,所有的表做所有操作。
mysql> grant all on *.* to [email protected]‘%‘ identified by ‘123‘;
Query OK, 0 rows affected (0.17 sec)
--重新整理生效,否則就要重啟MySQL服務才可以。
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
--瀏覽當前MySQL使用者資訊
mysql> select user,host,password from mysql.user;
+----------+-----------------+-------------------------------------------+
| user | host | password |
+----------+-----------------+-------------------------------------------+
| root | localhost | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| root | 127.0.0.1 | |
| | localhost | |
| zhangsan | % | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| admin | 192.168.112.132 | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+----------+-----------------+-------------------------------------------+
5 rows in set (0.00 sec)
-- 移除一些許可權
-- revoke:只刪除了使用者權限,但沒有刪除這個使用者
mysql> revoke insert,delete on *.* from [email protected] identified by‘123‘;
-- 查看指定使用者的許可權資訊
mysql> show grants for [email protected];
+------------------------------------------------------------------------------------------------------------+
| Grants for [email protected] |
+------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO ‘xbb‘@‘localhost‘ IDENTIFIED BY PASSWORD ‘*23AE809DDACAF96AF0FD78ED04B6A265E05AA257‘ |
+------------------------------------------------------------------------------------------------------------+
--drop user:刪除了整個使用者及其許可權(包括資料字典中的資料)
mysql> drop user ‘xbb‘@‘localhost‘;
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| root | 127.0.0.1 |
| debian-sys-maint | localhost |
| root | localhost |
| root | wangxg |
+------------------+-----------+
4 rows in set (0.00 sec)
MySQL伺服器的使用者權限管理