<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ### 1\. 默認字符集由latin1變為utf8mb4 在8.0版本之前,默認字符集為latin1,utf8指向的是utf8mb3,8.0版本默認字符集為utf8mb4,utf8默認指向的也是utf8mb4。 注:在Percona Server 8.0.15版本上測試,utf8仍然指向的是utf8mb3,與官方文檔有出入。 ~~~csharp Warning | 3719 | 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. | ~~~ ### 2\. MyISAM系統表全部換成InnoDB表 系統表全部換成事務型的innodb表,默認的MySQL實例將不包含任何MyISAM表,除非手動創建MyISAM表。 ~~~ruby # MySQL 5.7 mysql> select distinct(ENGINE) from information_schema.tables; +--------------------+ | ENGINE | +--------------------+ | MEMORY | | InnoDB | | MyISAM | | CSV | | PERFORMANCE_SCHEMA | | NULL | +--------------------+ 6 rows in set (0.00 sec) # MySQL 8.0 mysql> select distinct(ENGINE) from information_schema.tables; +--------------------+ | ENGINE | +--------------------+ | NULL | | InnoDB | | CSV | | PERFORMANCE_SCHEMA | +--------------------+ 4 rows in set (0.00 sec) ~~~ ### 3\. 自增變量持久化 在8.0之前的版本,自增主鍵AUTO\_INCREMENT的值如果大于max(primary key)+1,在MySQL重啟后,會重置AUTO\_INCREMENT=max(primary key)+1,這種現象在某些情況下會導致業務主鍵沖突或者其他難以發現的問題。自增主鍵重啟重置的問題很早就被發現([https://bugs.mysql.com/bug.php?id=199](https://links.jianshu.com/go?to=https%3A%2F%2Fbugs.mysql.com%2Fbug.php%3Fid%3D199)),一直到8.0才被解決,8.0版本將會對AUTO\_INCREMENT值進行持久化,MySQL重啟后,該值將不會改變。 ### 4\. DDL原子化 InnoDB表的DDL支持事務完整性,要么成功要么回滾,將DDL操作回滾日志寫入到data dictionary 數據字典表 mysql.innodb\_ddl\_log 中用于回滾操作,該表是隱藏的表,通過show tables無法看到。通過設置參數,可將ddl操作日志打印輸出到mysql錯誤日志中。 ~~~cpp mysql> set global log_error_verbosity=3; mysql> set global innodb_print_ddl_logs=1; mysql> create table t1(c int) engine=innodb; # MySQL錯誤日志: 2018-06-26T11:25:25.817245+08:00 44 [Note] [MY-012473] [InnoDB] InnoDB: DDL log insert : [DDL record: DELETE SPACE, id=41, thread_id=44, space_id=6, old_file_path=./db/t1.ibd] 2018-06-26T11:25:25.817369+08:00 44 [Note] [MY-012478] [InnoDB] InnoDB: DDL log delete : by id 41 2018-06-26T11:25:25.819753+08:00 44 [Note] [MY-012477] [InnoDB] InnoDB: DDL log insert : [DDL record: REMOVE CACHE, id=42, thread_id=44, table_id=1063, new_file_path=db/t1] 2018-06-26T11:25:25.819796+08:00 44 [Note] [MY-012478] [InnoDB] InnoDB: DDL log delete : by id 42 2018-06-26T11:25:25.820556+08:00 44 [Note] [MY-012472] [InnoDB] InnoDB: DDL log insert : [DDL record: FREE, id=43, thread_id=44, space_id=6, index_id=140, page_no=4] 2018-06-26T11:25:25.820594+08:00 44 [Note] [MY-012478] [InnoDB] InnoDB: DDL log delete : by id 43 2018-06-26T11:25:25.825743+08:00 44 [Note] [MY-012485] [InnoDB] InnoDB: DDL log post ddl : begin for thread id : 44 2018-06-26T11:25:25.825784+08:00 44 [Note] [MY-012486] [InnoDB] InnoDB: DDL log post ddl : end for thread id : 44 ~~~ 來看另外一個例子,庫里只有一個t1表,drop table t1,t2; 試圖刪除t1,t2兩張表,在5.7中,執行報錯,但是t1表被刪除,在8.0中執行報錯,但是t1表沒有被刪除,證明了8.0 DDL操作的原子性,要么全部成功,要么回滾。 ~~~ruby # MySQL 5.7 mysql> show tables; +---------------+ | Tables_in_db | +---------------+ | t1 | +---------------+ 1 row in set (0.00 sec) mysql> drop table t1, t2; ERROR 1051 (42S02): Unknown table 'db.t2' mysql> show tables; Empty set (0.00 sec) # MySQL 8.0 mysql> show tables; +---------------+ | Tables_in_db | +---------------+ | t1 | +---------------+ 1 row in set (0.00 sec) mysql> drop table t1, t2; ERROR 1051 (42S02): Unknown table 'db.t2' mysql> show tables; +---------------+ | Tables_in_db | +---------------+ | t1 | +---------------+ 1 row in set (0.00 sec) ~~~ ### 5\. 參數修改持久化 MySQL 8.0版本支持在線修改全局參數并持久化,通過加上PERSIST關鍵字,可以將修改的參數持久化到新的配置文件(mysqld-auto.cnf)中,重啟MySQL時,可以從該配置文件獲取到最新的配置參數。 例如執行: set PERSIST expire\_logs\_days=10 ; 系統會在數據目錄下生成一個包含json格式的 mysqld-auto.cnf 的文件,格式化后如下所示,當 my.cnf 和 mysqld-auto.cnf 同時存在時,后者具有更高優先級。 ~~~json { "Version": 1, "mysql_server": { "expire_logs_days": { "Value": "10", "Metadata": { "Timestamp": 1529657078851627, "User": "root", "Host": "localhost" } } } } ~~~ ### 6\. 新增降序索引 MySQL在語法上很早就已經支持降序索引,但實際上創建的仍然是升序索引,如下MySQL 5.7 所示,c2字段降序,但是從show create table看c2仍然是升序。8.0可以看到,c2字段降序。 ~~~go # MySQL 5.7 mysql> create table t1(c1 int,c2 int,index idx_c1_c2(c1,c2 desc)); Query OK, 0 rows affected (0.03 sec) mysql> show create table t1\G *************************** 1. row *************************** Table: t1 Create Table: CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` int(11) DEFAULT NULL, KEY `idx_c1_c2` (`c1`,`c2`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 1 row in set (0.00 sec) # MySQL 8.0 mysql> create table t1(c1 int,c2 int,index idx_c1_c2(c1,c2 desc)); Query OK, 0 rows affected (0.06 sec) mysql> show create table t1\G *************************** 1. row *************************** Table: t1 Create Table: CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` int(11) DEFAULT NULL, KEY `idx_c1_c2` (`c1`,`c2` DESC) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC 1 row in set (0.00 sec) ~~~ 再來看看降序索引在執行計劃中的表現,在t1表插入10萬條隨機數據,查看select \* from t1 order by c1 , c2 desc;的執行計劃。從執行計劃上可以看出,5.7的掃描數100113遠遠大于8.0的5行,并且使用了filesort。 ~~~ruby DELIMITER ;; CREATE PROCEDURE test_insert () BEGIN DECLARE i INT DEFAULT 1; WHILE i<100000 DO insert into t1 select rand()*100000, rand()*100000; SET i=i+1; END WHILE ; commit; END;; DELIMITER ; CALL test_insert(); # MySQL 5.7 mysql> explain select * from t1 order by c1 , c2 desc limit 5; +----+-------------+-------+------------+-------+---------------+-----------+---------+------+--------+----------+-----------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+-------+---------------+-----------+---------+------+--------+----------+-----------------------------+ | 1 | SIMPLE | t1 | NULL | index | NULL | idx_c1_c2 | 10 | NULL | 100113 | 100.00 | Using index; Using filesort | +----+-------------+-------+------------+-------+---------------+-----------+---------+------+--------+----------+-----------------------------+ 1 row in set, 1 warning (0.00 sec) # MySQL 8.0 mysql> explain select * from t1 order by c1 , c2 desc limit 5; +----+-------------+-------+------------+-------+---------------+-----------+---------+------+------+----------+-------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+-------+---------------+-----------+---------+------+------+----------+-------------+ | 1 | SIMPLE | t1 | NULL | index | NULL | idx_c1_c2 | 10 | NULL | 5 | 100.00 | Using index | +----+-------------+-------+------------+-------+---------------+-----------+---------+------+------+----------+-------------+ 1 row in set, 1 warning (0.00 sec) ~~~ 降序索引只是對查詢中特定的排序順序有效,如果使用不當,反而查詢效率更低,比如上述查詢排序條件改為 order by c1 desc, c2 desc,這種情況下,5.7的執行計劃要明顯好于8.0的,如下: ~~~ruby # MySQL 5.7 mysql> explain select * from t1 order by c1 desc , c2 desc limit 5; +----+-------------+-------+------------+-------+---------------+-----------+---------+------+------+----------+-------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+-------+---------------+-----------+---------+------+------+----------+-------------+ | 1 | SIMPLE | t1 | NULL | index | NULL | idx_c1_c2 | 10 | NULL | 5 | 100.00 | Using index | +----+-------------+-------+------------+-------+---------------+-----------+---------+------+------+----------+-------------+ 1 row in set, 1 warning (0.01 sec) # MySQL 8.0 mysql> explain select * from t1 order by c1 desc , c2 desc limit 5; +----+-------------+-------+------------+-------+---------------+-----------+---------+------+--------+----------+-----------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+-------+---------------+-----------+---------+------+--------+----------+-----------------------------+ | 1 | SIMPLE | t1 | NULL | index | NULL | idx_c1_c2 | 10 | NULL | 100429 | 100.00 | Using index; Using filesort | +----+-------------+-------+------------+-------+---------------+-----------+---------+------+--------+----------+-----------------------------+ 1 row in set, 1 warning (0.01 sec) ~~~ ### 7\. group by 不再隱式排序 mysql 8.0 對于group by 字段不再隱式排序,如需要排序,必須顯式加上order by 子句。 ~~~ruby # 表結構 mysql> show create table tb1\G *************************** 1. row *************************** Table: tb1 Create Table: CREATE TABLE `tb1` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, `group_own` int(11) DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC 1 row in set (0.00 sec) # 表數據 mysql> select * from tb1; +----+------+-----------+ | id | name | group_own | +----+------+-----------+ | 1 | 1 | 0 | | 2 | 2 | 0 | | 3 | 3 | 0 | | 4 | 4 | 0 | | 5 | 5 | 5 | | 8 | 8 | 1 | | 10 | 10 | 5 | +----+------+-----------+ 7 rows in set (0.00 sec) # MySQL 5.7 mysql> select count(id), group_own from tb1 group by group_own; +-----------+-----------+ | count(id) | group_own | +-----------+-----------+ | 4 | 0 | | 1 | 1 | | 2 | 5 | +-----------+-----------+ 3 rows in set (0.00 sec) # MySQL 8.0.11 mysql> select count(id), group_own from tb1 group by group_own; +-----------+-----------+ | count(id) | group_own | +-----------+-----------+ | 4 | 0 | | 2 | 5 | | 1 | 1 | +-----------+-----------+ 3 rows in set (0.00 sec) # MySQL 8.0.11顯式地加上order by進行排序 mysql> select count(id), group_own from tb1 group by group_own order by group_own; +-----------+-----------+ | count(id) | group_own | +-----------+-----------+ | 4 | 0 | | 1 | 1 | | 2 | 5 | +-----------+-----------+ 3 rows in set (0.00 sec) ~~~ ### 8\. JSON特性增強 MySQL 8 大幅改進了對 JSON 的支持,添加了基于路徑查詢參數從 JSON 字段中抽取數據的 JSON\_EXTRACT() 函數,以及用于將數據分別組合到 JSON 數組和對象中的 JSON\_ARRAYAGG() 和 JSON\_OBJECTAGG() 聚合函數。 在主從復制中,新增參數 binlog\_row\_value\_options,控制JSON數據的傳輸方式,允許對于Json類型部分修改,在binlog中只記錄修改的部分,減少json大數據在只有少量修改的情況下,對資源的占用。 ### 9\. redo & undo 日志加密 增加以下兩個參數,用于控制redo、undo日志的加密。 [innodb\_undo\_log\_encrypt](https://links.jianshu.com/go?to=https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F8.0%2Fen%2Finnodb-parameters.html%23sysvar_innodb_undo_log_encrypt) [innodb\_undo\_log\_encrypt](https://links.jianshu.com/go?to=https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F8.0%2Fen%2Finnodb-parameters.html%23sysvar_innodb_undo_log_encrypt) ### 10\. innodb select for update跳過鎖等待 select ... for update,select ... for share(8.0新增語法) 添加 NOWAIT、SKIP LOCKED語法,跳過鎖等待,或者跳過鎖定。 在5.7及之前的版本,select...for update,如果獲取不到鎖,會一直等待,直到innodb\_lock\_wait\_timeout超時。 在8.0版本,通過添加nowait,skip locked語法,能夠立即返回。如果查詢的行已經加鎖,那么nowait會立即報錯返回,而skip locked也會立即返回,只是返回的結果中不包含被鎖定的行。 ~~~csharp # session1: mysql> begin; mysql> select * from t1 where c1 = 2 for update; +------+-------+ | c1 | c2 | +------+-------+ | 2 | 60530 | | 2 | 24678 | +------+-------+ 2 rows in set (0.00 sec) # session2: mysql> select * from t1 where c1 = 2 for update nowait; ERROR 3572 (HY000): Statement aborted because lock(s) could not be acquired immediately and NOWAIT is set. mysql> select * from t1 where c1 = 2 for update skip locked; Empty set (0.00 sec) ~~~ ### 11\. 增加SET\_VAR語法 在sql語法中增加SET\_VAR語法,動態調整部分參數,有利于提升語句性能。 * select /\*+ SET\_VAR(sort\_buffer\_size = 16M) \*/ id from test order id ; * insert /\*+ SET\_VAR(foreign\_key\_checks=OFF) \*/ into test(name) values(1); ### 12\. 支持不可見索引 使用INVISIBLE關鍵字在創建表或者進行表變更中設置索引是否可見。索引不可見只是在查詢時優化器不使用該索引,即使使用force index,優化器也不會使用該索引,同時優化器也不會報索引不存在的錯誤,因為索引仍然真實存在,在必要時,也可以快速的恢復成可見。 ~~~csharp # 創建不可見索引 create table t2(c1 int,c2 int,index idx_c1_c2(c1,c2 desc) invisible ); # 索引可見 alter table t2 alter index idx_c1_c2 visible; # 索引不可見 alter table t2 alter index idx_c1_c2 invisible; ~~~ ### 13\. 支持直方圖 優化器會利用column\_statistics的數據,判斷字段的值的分布,得到更準確的執行計劃。 可以使用 ANALYZE TABLE table\_name \[UPDATE HISTOGRAM on col\_name with N BUCKETS |DROP HISTOGRAM ON clo\_name\] 來收集或者刪除直方圖信息。 直方圖統計了表中某些字段的數據分布情況,為優化選擇高效的執行計劃提供參考,直方圖與索引有著本質的區別,維護一個索引有代價。每一次的insert、update、delete都會需要更新索引,會對性能有一定的影響。而直方圖一次創建永不更新,除非明確去更新它。所以不會影響insert、update、delete的性能。 ~~~ruby # 添加/更新直方圖 mysql> analyze table t1 update histogram on c1, c2 with 32 buckets; +--------+-----------+----------+-----------------------------------------------+ | Table | Op | Msg_type | Msg_text | +--------+-----------+----------+-----------------------------------------------+ | db.t1 | histogram | status | Histogram statistics created for column 'c1'. | | db.t1 | histogram | status | Histogram statistics created for column 'c2'. | +--------+-----------+----------+-----------------------------------------------+ 2 rows in set (2.57 sec) # 刪除直方圖 mysql> analyze table t1 drop histogram on c1, c2; +--------+-----------+----------+-----------------------------------------------+ | Table | Op | Msg_type | Msg_text | +--------+-----------+----------+-----------------------------------------------+ | db.t1 | histogram | status | Histogram statistics removed for column 'c1'. | | db.t1 | histogram | status | Histogram statistics removed for column 'c2'. | +--------+-----------+----------+-----------------------------------------------+ 2 rows in set (0.13 sec) ~~~ ### 14\. 新增innodb\_dedicated\_server參數 能夠讓InnoDB根據服務器上檢測到的內存大小自動配置innodb\_buffer\_pool\_size,innodb\_log\_file\_size,innodb\_flush\_method三個參數。 ### 15\. 日志分類更詳細 在錯誤信息中添加了錯誤信息編號\[MY-010311\]和錯誤所屬子系統\[Server\] ~~~bash # MySQL 5.7 2018-06-08T09:07:20.114585+08:00 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. 2018-06-08T09:07:20.117848+08:00 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode. 2018-06-08T09:07:20.117868+08:00 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. # MySQL 8.0 2018-06-21T17:53:13.040295+08:00 28 [Warning] [MY-010311] [Server] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. 2018-06-21T17:53:13.040520+08:00 28 [Warning] [MY-010330] [Server] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode. 2018-06-21T17:53:13.040542+08:00 28 [Warning] [MY-010330] [Server] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. ~~~ ### 16\. undo空間自動回收 * innodb\_undo\_log\_truncate參數在8.0.2版本默認值由OFF變為ON,默認開啟undo日志表空間自動回收。 * innodb\_undo\_tablespaces參數在8.0.2版本默認為2,當一個undo表空間被回收時,還有另外一個提供正常服務。 * innodb\_max\_undo\_log\_size參數定義了undo表空間回收的最大值,當undo表空間超過這個值,該表空間被標記為可回收。 ### 17\. 增加資源組 MySQL 8.0新增了一個資源組功能,用于調控線程優先級以及綁定CPU核。 MySQL用戶需要有 RESOURCE\_GROUP\_ADMIN權限才能創建、修改、刪除資源組。 在Linux環境下,MySQL進程需要有 CAP\_SYS\_NICE 權限才能使用資源組完整功能。 ~~~csharp [root@localhost~]# sudo setcap cap_sys_nice+ep /usr/local/mysql8.0/bin/mysqld [root@localhost~]# getcap /usr/local/mysql8.0/bin/mysqld /usr/local/mysql8.0/bin/mysqld = cap_sys_nice+ep ~~~ 默認提供兩個資源組,分別是USR\_default,SYS\_default 創建資源組: create resource group test\_resouce\_group type=USER vcpu=0,1 thread\_priority=5; 將當前線程加入資源組: SET RESOURCE GROUP test\_resouce\_group; 將某個線程加入資源組: SET RESOURCE GROUP test\_resouce\_group FOR thread\_id; 查看資源組里有哪些線程: select \* from Performance\_Schema.threads where RESOURCE\_GROUP='test\_resouce\_group'; 修改資源組: alter resource group test\_resouce\_group vcpu = 2,3 THREAD\_PRIORITY = 8; 刪除資源組 : drop resource group test\_resouce\_group; ~~~ruby # 創建資源組 mysql>create resource group test_resouce_group type=USER vcpu=0,1 thread_priority=5; Query OK, 0 rows affected (0.03 sec) mysql> select * from RESOURCE_GROUPS; +---------------------+---------------------+------------------------+----------+-----------------+ | RESOURCE_GROUP_NAME | RESOURCE_GROUP_TYPE | RESOURCE_GROUP_ENABLED | VCPU_IDS | THREAD_PRIORITY | +---------------------+---------------------+------------------------+----------+-----------------+ | USR_default | USER | 1 | 0-3 | 0 | | SYS_default | SYSTEM | 1 | 0-3 | 0 | | test_resouce_group | USER | 1 | 0-1 | 5 | +---------------------+---------------------+------------------------+----------+-----------------+ 3 rows in set (0.00 sec) # 把線程id為60的線程加入到資源組test_resouce_group中,線程id可通過Performance_Schema.threads獲取 mysql> SET RESOURCE GROUP test_resouce_group FOR 60; Query OK, 0 rows affected (0.00 sec) # 資源組里有線程時,刪除資源組報錯 mysql> drop resource group test_resouce_group; ERROR 3656 (HY000): Resource group test_resouce_group is busy. # 修改資源組 mysql> alter resource group test_resouce_group vcpu = 2,3 THREAD_PRIORITY = 8; Query OK, 0 rows affected (0.10 sec) mysql> select * from RESOURCE_GROUPS; +---------------------+---------------------+------------------------+----------+-----------------+ | RESOURCE_GROUP_NAME | RESOURCE_GROUP_TYPE | RESOURCE_GROUP_ENABLED | VCPU_IDS | THREAD_PRIORITY | +---------------------+---------------------+------------------------+----------+-----------------+ | USR_default | USER | 1 | 0-3 | 0 | | SYS_default | SYSTEM | 1 | 0-3 | 0 | | test_resouce_group | USER | 1 | 2-3 | 8 | +---------------------+---------------------+------------------------+----------+-----------------+ 3 rows in set (0.00 sec) # 把資源組里的線程移出到默認資源組USR_default mysql> SET RESOURCE GROUP USR_default FOR 60; Query OK, 0 rows affected (0.00 sec) # 刪除資源組 mysql> drop resource group test_resouce_group; Query OK, 0 rows affected (0.04 sec) ~~~ #### 18\. 增加角色管理 角色可以認為是一些權限的集合,為用戶賦予統一的角色,權限的修改直接通過角色來進行,無需為每個用戶單獨授權。 ~~~ruby # 創建角色 mysql> create role role_test; Query OK, 0 rows affected (0.03 sec) # 給角色授予權限 mysql> grant select on db.* to 'role_test'; Query OK, 0 rows affected (0.10 sec) # 創建用戶 mysql> create user 'read_user'@'%' identified by '123456'; Query OK, 0 rows affected (0.09 sec) # 給用戶賦予角色 mysql> grant 'role_test' to 'read_user'@'%'; Query OK, 0 rows affected (0.02 sec) # 給角色role_test增加insert權限 mysql> grant insert on db.* to 'role_test'; Query OK, 0 rows affected (0.08 sec) # 給角色role_test刪除insert權限 mysql> revoke insert on db.* from 'role_test'; Query OK, 0 rows affected (0.10 sec) # 查看默認角色信息 mysql> select * from mysql.default_roles; +------+-----------+-------------------+-------------------+ | HOST | USER | DEFAULT_ROLE_HOST | DEFAULT_ROLE_USER | +------+-----------+-------------------+-------------------+ | % | read_user | % | role_test | +------+-----------+-------------------+-------------------+ 1 row in set (0.00 sec) # 查看角色與用戶關系 mysql> select * from mysql.role_edges; +-----------+-----------+---------+-----------+-------------------+ | FROM_HOST | FROM_USER | TO_HOST | TO_USER | WITH_ADMIN_OPTION | +-----------+-----------+---------+-----------+-------------------+ | % | role_test | % | read_user | N | +-----------+-----------+---------+-----------+-------------------+ 1 row in set (0.00 sec) # 刪除角色 mysql> drop role role_test; Query OK, 0 rows affected (0.06 sec) ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看