http://yanue.net/post-96.htmlhtml
MySQL查看用戶權限命令的兩方法:mysql
MySQL grant詳細用法見:http://yanue.net/post-97.html使用方法:sql
實例:
- mysql> show grants for username@localhost;
- mysql> show grants for root@localhost;
- +---------------------------------------------------------------------+
- | Grants for root@localhost |
- +---------------------------------------------------------------------+
- | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
- +---------------------------------------------------------------------+
- 1 row in set (0.01 sec)
- mysql> select * from mysql.user where user='test' and host='127.0.0.1' \G;
- *************************** 1. row ***************************
- Host: 127.0.0.1
- User: test
- Password: *EB3C643405D7F53BD4BF7FBA98DCF5641E228833
- Select_priv: N
- Insert_priv: N
- Update_priv: N
- Delete_priv: N
- Create_priv: N
- Drop_priv: N
- Reload_priv: N
- Shutdown_priv: N
- Process_priv: N
- File_priv: N
- Grant_priv: N
- References_priv: N
- Index_priv: N
- Alter_priv: N
- Show_db_priv: N
- Super_priv: N
- Create_tmp_table_priv: N
- Lock_tables_priv: N
- Execute_priv: N
- Repl_slave_priv: N
- Repl_client_priv: N
- Create_view_priv: N
- Show_view_priv: N
- Create_routine_priv: N
- Alter_routine_priv: N
- Create_user_priv: N
- Event_priv: N
- Trigger_priv: N
- Create_tablespace_priv: N
- ssl_type:
- ssl_cipher:
- x509_issuer:
- x509_subject:
- max_questions: 0
- max_updates: 0
- max_connections: 0
- max_user_connections: 0
- plugin: mysql_native_password
- authentication_string:
- password_expired: N
- 1 row in set (0.00 sec)
能夠看到Select_priv,Insert_priv,Update_priv...等爲N表示沒有權限,該用戶權限一目瞭然.這時能夠使用命令數據庫
給用戶加權限:ide
見http://www.yanue.net/post-97.htmlpost
另外:show能夠看到不少東西:
- grant all privileges on *.* to 'test'@'127.0.0.1' identified by 'passwd';
- flush privileges;
- show databases;
- show tables;
- show create database dbname; // 這個能夠看到建立數據庫時用到的一些參數。
- show create table tablename; // 能夠看到建立表時用到的一些參數