查詢 MySQL 對 此帳號 開放(GRANT)哪些權限
查詢 某 User 的權限
- SELECT User,Host FROM mysql.user; # 秀出系統現在有哪些 user
- SHOW GRANTS FOR username@localhost; # 會秀出開此 username 時下的 Grant 語法, 也可用此來做帳號備份.
- 結果: GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'username'@'localhost' IDENTIFIED BY PASSWORD '$PASSWORD'
- SHOW GRANTS FOR root@localhost; # 會秀出開此 User 時下的 Grant 語法, 也可用此來做帳號備份.
- 結果: GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '$PASSWORD' WITH GRANT OPTION
列出 目前此User 的權限.
- SHOW GRANTS;
- SHOW GRANTS FOR CURRENT_USER;
- SHOW GRANTS FOR CURRENT_USER();