MySQL用戶的操作命令

1. 新建用戶

mysql> create user oldboy@'10.0.0.%' identified by '123';
Query OK, 0 rows affected (0.00 sec)

  說明:
   8.0以前,可以自動創建用戶並授權

mysql> grant all on *.* to oldguo@'10.0.0.%' identified by '123';

2. 查詢用戶

mysql> select user,host from mysql.user;
+---------------+-----------+
| user          | host      |
+---------------+-----------+
| southbay      | 10.0.0.%  |
| mysql.session | localhost |
| mysql.sys     | localhost |
| root          | localhost |
+---------------+-----------+
4 rows in set (0.00 sec)

3. 修改用戶密碼

mysql> alter user southbay@'10.0.0.%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

4. 刪除用戶

mysql> drop user southbay@'10.0.0.%';
Query OK, 0 rows affected (0.00 sec)

5. 權限授權

mysql> grant all on *.* to southbay@'10.0.0.%' identified by '123' with grant option;

with grant option    -----賦予管理員權限

權限列表:
ALL
SELECT,INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE

6. 查看權限

mysql> show grants for southbay@'10.0.0.%';
+---------------------------------------------+
| Grants for [email protected].%                |
+---------------------------------------------+
| GRANT USAGE ON *.* TO 'southbay'@'10.0.0.%' |
+---------------------------------------------+
1 row in set (0.00 sec)

7. 回收權限

mysql> revoke delete on *.* from southbay@'10.0.0.%';
Query OK, 0 rows affected (0.00 sec)


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章