{"id":7530,"date":"2018-06-03T10:25:02","date_gmt":"2018-06-03T02:25:02","guid":{"rendered":"http:\/\/rmohan.com\/?p=7530"},"modified":"2018-06-03T10:27:30","modified_gmt":"2018-06-03T02:27:30","slug":"full-understanding-of-the-new-features-of-mysql-8-0","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7530","title":{"rendered":"Full understanding of the new features of MySQL 8.0"},"content":{"rendered":"<h1 class=\"aTitle\">Full understanding of the new features of MySQL 8.0<\/h1>\n<p>First, the function added in MySQL 8.0<\/p>\n<p>1, the new system dictionary table<\/p>\n<p>Integrated transaction data dictionary for storing information about database objects, all metadata is stored using the InnoDB engine<\/p>\n<p>2, support for DDL atomic operations<\/p>\n<p>The DDL of the InnoDB table supports transaction integrity, either to be successful or to roll back, to write the DDL operation rollback log to the data dictionary data dictionary table mysql.innodb_ddl_log for rollback operations<\/p>\n<p>3, security and user management<\/p>\n<p>Added caching_sha2_password authentication plugin and is the default authentication plugin.\u00a0Enhanced performance and security<\/p>\n<p>Permissions support role<\/p>\n<p>New password history feature restricts reuse of previous passwords<\/p>\n<p>4, support for resource management<\/p>\n<p>Supports creation and management of resource groups and allows the allocation of threads run by the server to specific groups for execution by threads based on the resources available to the resource group<\/p>\n<p>5, innodb enhancements<\/p>\n<p>Self-enhanced optimization to fix MySQL bug#199, this bug causes MySQL to take the maximum self-increment on the table as the maximum when the DB is restarted, and the next allocation is to allocate max(id)+1 if it is an archive table or After the data is deleted in other modes, the DB system restarts, and self-enhancement may be reused.<\/p>\n<p>Added INFORMATION_SCHEMA.INNODB_CACHED_INDEXES to see the index pages of each index cache in the InnoDB buffer pool<\/p>\n<p>InnoDB temporary tables will be created in the shared temporary table space ibtmp1<\/p>\n<p>InnoDB supports NOWAIT and SKIP LOCKED for SELECT &#8230; FOR SHARE and SELECT &#8230; FOR UPDATE statements<\/p>\n<p>The minimum value of innodb_undo_tablespaces is 2, and it is no longer allowed to set innodb_undo_tablespaces to 0.\u00a0Min 2 ensures that rollback segments are always created in the undo tablespace, not in the system tablespace<\/p>\n<p>ALTER TABLESPACE &#8230; RENAME TO syntax<\/p>\n<p>Added innodb_dedicated_server to let InnoDB automatically configure innodb_buffer_pool_size according to the amount of memory detected on the server, innodb_log_file_size, innodb_flush_method<\/p>\n<p>New INFORMATION_SCHEMA.INNODB_TABLESPACES_BRIEF view<\/p>\n<p>A new dynamic configuration item, innodb_deadlock_detect, is used to disable deadlock checking, because in high-concurrency systems, when a large number of threads wait for the same lock, deadlock checking can significantly slow down the database.<\/p>\n<p>Supports use of the innodb_directories option to move or restore tablespace files to a new location when the server is offline<\/p>\n<p>6, MySQL 8.0 better support for document database and JSON<\/p>\n<p>7, optimization<\/p>\n<p>Invisible index, starting to support invisible index, (feeling the\u00a0same as\u00a0<a title=\"Oracle\" href=\"https:\/\/www.linuxidc.com\/topicnews.aspx?tid=12\" target=\"_blank\" rel=\"noopener\">Oracle<\/a>\u00a0), you can set the index to be invisible during the optimization of the SQL, the optimizer will not use the invisible index<\/p>\n<p>Support descending index, DESC can be defined on the index, before the index can be reversed scan, but affect performance, and descending index can be completed efficiently<\/p>\n<p>8, support RANK (), LAG (), NTILE () and other functions<\/p>\n<p>9, regular expression enhancements, provide REGEXP_LIKE (), EGEXP_INSTR (), REGEXP_REPLACE (), REGEXP_SUBSTR () and other functions<\/p>\n<p>10. Add a backup lock to allow DML during online backup while preventing operations that may result in inconsistent snapshots.\u00a0Backup locks supported by LOCK INSTANCE FOR BACKUP and UNLOCK INSTANCE syntax<\/p>\n<p>11, the character set The default character set changed from latin1 to utf8mb4<\/p>\n<p>12, configuration file enhancement<\/p>\n<p>MySQL 8.0 supports online modification of global parameter persistence. By adding the PERSIST keyword, you can persist the adjustment to a new configuration file. Restarting db can also be applied to the latest parameters.\u00a0For adding the PERSIST keyword modification parameter command, the MySQL system will generate a mysqld-auto.cnf file that contains json format data. For example, execute:<\/p>\n<p>Set PERSIST expire_logs_days=10 ; # memory and json files are modified, restart also effective<\/p>\n<p>Set GLOBAL expire_logs_days=10 ; # only modify memory, restart lost<\/p>\n<p>The system will generate a file containing the following in the data directory mysqld-auto.cnf:<\/p>\n<p>{ &#8220;mysql_server&#8221;: {&#8220;expire_logs_days&#8221;: &#8220;10&#8221; } }<\/p>\n<p>When my.cnf and mysqld-auto.cnf exist at the same time, the latter has a high priority.<\/p>\n<p>13. Histogram<\/p>\n<p>The MySQL 8.0 version started to support long-awaited histograms.\u00a0The optimizer will use the column_statistics data to determine the distribution of field values ??and get a more accurate execution plan.<\/p>\n<p>You can use ANALYZE TABLE table_name [UPDATE HISTOGRAM on col_name with N BUCKETS | DROP HISTOGRAM ON clo_name] to collect or delete histogram information<\/p>\n<p>14, support for session-level SET_VAR dynamically adjust some of the parameters, help to improve statement performance.<\/p>\n<p>Select \/*+ SET_VAR(sort_buffer_size = 16M) *\/ id from test order id ;<\/p>\n<p>Insert \/*+ SET_VAR(foreign_key_checks=OFF) *\/ into test(name) values(1);<\/p>\n<p>15, the adjustment of the default parameters<\/p>\n<p>Adjust the default value of back_log to keep the same with max_connections and increase the connection processing capacity brought by burst traffic.<\/p>\n<p>Modifying event_scheduler defaults to ON, which was previously disabled by default.<\/p>\n<p>Adjust the default value of max_allowed_packet from 4M to 64M.<\/p>\n<p>Adjust bin_log, log_slave_updates default is on.<\/p>\n<p>Adjust the expiry date of expire_logs_days to 30 days, and the old version to 7 days. In the production environment, check this parameter to prevent the binlog from creating too much space.<\/p>\n<p>Adjust innodb_undo_log_truncate to ON by default<\/p>\n<p>Adjust the default value of innodb_undo_tablespaces to 2<\/p>\n<p>Adjust the innodb_max_dirty_pages_pct_lwm default 10<\/p>\n<p>Adjust the default value of innodb_max_dirty_pages_pct 90<\/p>\n<p>Added innodb_autoinc_lock_mode default value 2<\/p>\n<p>16, InnoDB performance improvement<\/p>\n<p>Abandon the buffer pool mutex, split the original mutex into multiple, increase concurrent<\/p>\n<p>Splitting the two mutexes LOCK_thd_list and LOCK_thd_remove can increase the threading efficiency by approximately 5%.<\/p>\n<p>17, line buffer<\/p>\n<p>The MySQL8.0 optimizer can estimate the number of rows to be read, so it can provide the storage engine with an appropriately sized row buffer to store the required data.\u00a0Mass performance of continuous data scans will benefit from larger record buffers<\/p>\n<p>18, improve the scanning performance<\/p>\n<p>Improving the performance of InnoDB range queries improves the performance of full-table queries and range queries by 5-20%.<\/p>\n<p>19, the cost model<\/p>\n<p>The InnoDB buffer can estimate how many tables and indexes are in the cache, which allows the optimizer to choose the access mode to know if the data can be stored in memory or must be stored on disk.<\/p>\n<p>20, refactoring SQL analyzer<\/p>\n<p>Improve the SQL analyzer.\u00a0The old analyzer has serious limitations due to its grammatical complexity and top-down analysis, making it difficult to maintain and extend.<\/p>\n<p><strong>Second, MySQL 8.0 in the abandoned features<\/strong><\/p>\n<ul>\n<li>Deprecated validate_password plugin<\/li>\n<li>Deprecation of ALTER TABLESPACE and DROP TABLESPACE ENGINE Clauses<\/li>\n<li>Discard JSON_MERGE() -&gt; JSON_MERGE_PRESERVE() instead<\/li>\n<li>Abandoned have_query_cache system variable<\/li>\n<\/ul>\n<p><strong>Third, MySQL 8.0 is removed<\/strong><\/p>\n<p>Query cache functionality was removed and related system variables were also removed<\/p>\n<p>Mysql_install_db is replaced by mysqld &#8211;initialize or &#8211;initialize-insecure<\/p>\n<p>The INNODB_LOCKS and INNODB_LOCK_WAITS tables under INFORMATION_SCHEMA have been deleted.\u00a0Replaced with Performance Schema data_locks and data_lock_waits tables<\/p>\n<p>Four tables under INFORMATION_SCHEMA removed: GLOBAL_VARIABLES, SESSION_VARIABLES, GLOBAL_STATUS, SESSION_STATUS<\/p>\n<p>InnoDB no longer supports compressed temporary tables.<\/p>\n<p><strong>PROCEDURE ANALYSE() syntax is no longer supported<\/strong><\/p>\n<p>InnoDB Information Schema Views Renamed<br \/>\nOld the Name the Name New<br \/>\nINNODB_SYS_COLUMNS INNODB_COLUMNS<br \/>\nINNODB_SYS_DATAFILES INNODB_DATAFILES<br \/>\nINNODB_SYS_FIELDS INNODB_FIELDS<br \/>\nINNODB_SYS_FOREIGN INNODB_FOREIGN<br \/>\nINNODB_SYS_FOREIGN_COLS INNODB_FOREIGN_COLS<br \/>\nINNODB_SYS_INDEXES INNODB_INDEXES<br \/>\nINNODB_SYS_TABLES INNODB_TABLES<br \/>\nINNODB_SYS_TABLESPACES INNODB_TABLESPACES<br \/>\nINNODB_SYS_TABLESTATS INNODB_TABLESTATS<br \/>\nINNODB_SYS_VIRTUAL INNODB_VIRTUAL<\/p>\n<p><strong>Remove&#8217;s server option:<\/strong><\/p>\n<p>&#8211;temp-pool<br \/>\n&#8211;ignore-builtin-innodb<br \/>\n&#8211;des-key-file<br \/>\n&#8211;log-warnings<br \/>\n&#8211;ignore-db-dir<\/p>\n<p><strong>Remove configuration options:<\/strong><\/p>\n<p>Innodb_file_format<br \/>\ninnodb_file_format_check<br \/>\ninnodb_file_format_max<br \/>\ninnodb_large_prefix<\/p>\n<p><strong>Remove the system variable<\/strong><\/p>\n<p>information_schema_stats -&gt; information_schema_stats_expiry<br \/>\nignore_builtin_innodb<br \/>\ninnodb_support_xa<br \/>\nshow_compatibility_56<br \/>\nhave_crypt<br \/>\nDATE_FORMAT<br \/>\nDATETIME_FORMAT<br \/>\nthe time_format<br \/>\nmax_tmp_tables<br \/>\nglobal.sql_log_bin (session.sql_log_bin reserved)<br \/>\nlog_warnings -&gt; log_error_verbosity<br \/>\nmulti_range_count<br \/>\nsecure_auth<br \/>\nsync_frm<br \/>\nTX_ISOLATION -&gt; transaction_isolation<br \/>\ntx_read_only -&gt; transaction_read_only<br \/>\nignore_db_dirs<br \/>\nthe query_cache_limit<br \/>\nthe query_cache_min_res_unit<br \/>\nthe query_cache_size<br \/>\nthe query_cache_type<br \/>\nquery_cache_wlock_invalidate<br \/>\ninnodb_undo_logs -&gt; innodb_rollback_segments<\/p>\n<p><strong>Remove the state variable<\/strong><\/p>\n<p>Com_alter_db_upgrade<br \/>\nSlave_heartbeat_period<br \/>\nSlave_last_heartbeat<br \/>\nSlave_received_heartbeats<br \/>\nSlave_retried_transactions, Slave_running<br \/>\nQcache_free_blocks<br \/>\nQcache_free_memory<br \/>\nQcache_hits<br \/>\nQcache_inserts<br \/>\nQcache_lowmem_prunes<br \/>\nQcache_not_cached<br \/>\nQcache_queries_in_cache<br \/>\nQcache_total_blocks<br \/>\nInnodb_available_undo_logs Status<\/p>\n<p><strong>Remove function<\/strong><\/p>\n<p>JSON_APPEND() &#8211;&gt; JSON_ARRAY_APPEND()<\/p>\n<p>ENCODE()<\/p>\n<p>DECODE()<\/p>\n<p>DES_ENCRYPT()<\/p>\n<p>DES_DECRYPT()<\/p>\n<p><strong>Remove&#8217;s client option:<\/strong><\/p>\n<p>&#8211;ssl &#8211;ssl-verify-server-cert is deleted, with &#8211;ssl-mode = VERIFY_IDENTITY | alternative DISABLED | REQUIRED<\/p>\n<p>&#8211;secure-auth<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>MySQL 8 official version 8.0.11 has been released. Officially stated that MySQL 8 is 2 times faster than MySQL 5.7, and it also brings a lot of improvements and faster performance!<\/p>\n<p>The following is the record of the installation process of the person 2018.4.23 days.\u00a0The entire process takes about an hour, and the make &amp;&amp; make install process takes longer.<\/p>\n<p>I. Environment<\/p>\n<p><a title=\"CentOS\" href=\"https:\/\/www.linuxidc.com\/topicnews.aspx?tid=14\" target=\"_blank\" rel=\"noopener\">CentOS<\/a>\u00a07.4 64-bit Minimal Installation<\/p>\n<p>II. Preparation<\/p>\n<p>??1. Installation dependencies<\/p>\n<p>Yum -y install wget cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel<\/p>\n<p>??2. Download the source package<\/p>\n<p>Wget https:\/\/cdn.mysql.com\/\/Downloads\/MySQL-8.0\/mysql-boost-8.0.11.tar.gz (this version comes with boost)<\/p>\n<p>??Create mysql user<\/p>\n<p>Groupadd mysql<br \/>\nuseradd -r -g mysql -s \/bin\/false mysql<\/p>\n<p>??4 create an installation directory and data directory<\/p>\n<p>Mkdir -p \/usr\/local\/mysql<br \/>\nmkdir -p \/data\/mysql<\/p>\n<p>Three. Install MySQL8.0.11<\/p>\n<p>??1. Extract the source package<\/p>\n<p>Tar -zxf mysql-boost-8.0.11.tar.gz -C \/usr\/local<\/p>\n<p>??2. Compile &amp; Install<\/p>\n<p>Cd \/usr\/local\/mysql-8.0.11<br \/>\ncmake . -DCMAKE_INSTALL_PREFIX=\/usr\/local\/mysql -DMYSQL_DATADIR=\/usr\/local\/mysql\/data -DSYSCONFDIR=\/etc -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=\/usr\/local\/ Mysql-8.0.11\/boost<br \/>\nmake &amp;&amp; make install<\/p>\n<p>3. Configure the my.cnf file<\/p>\n<p>Cat \/etc\/my.cnf<br \/>\n[mysqld]<br \/>\nserver-id=1<br \/>\nport=3306<br \/>\nbasedir=\/usr\/local\/mysql<br \/>\ndatadir=\/data\/mysql<\/p>\n<p>## Please add parameters according to the actual situation<\/p>\n<p>4 directory permissions modify<\/p>\n<p>Chown -R mysql:mysql \/usr\/local\/mysql<br \/>\nchown -R mysql:mysql \/data\/mysql<br \/>\nchmod 755 \/usr\/local\/mysql -R<br \/>\nchmod 755 \/data\/mysql -R<\/p>\n<p>5. Initialization<\/p>\n<p>Bin\/mysqld &#8211;initialize &#8211;user=mysql &#8211;datadir=\/data\/mysql\/<br \/>\nbin\/mysql_ssl_rsa_setup<\/p>\n<p>6. Start mysql<\/p>\n<p>Bin\/mysqld_safe &#8211;user=mysql &amp;<\/p>\n<p>??7. Modify account password<\/p>\n<p>Bin\/mysql -uroot -p<br \/>\nmysql&gt; alter user &#8216;root&#8217;@&#8217;localhost&#8217; identified by &#8220;123456&#8221;;<\/p>\n<p>Mysql&gt; show databases;<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br \/>\n| Database |<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- &#8211; +<br \/>\n| information_schema |<br \/>\n| mysql |<br \/>\n| performance_schema |<br \/>\n| sys |<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br \/>\n4 rows in set (0.00 sec)<\/p>\n<p>##Add Remote Account<\/p>\n<p>Mysql&gt; create user root@&#8217;%&#8217; identified by &#8216;123456&#8217;;<br \/>\nQuery OK, 0 rows affected (0.08 sec)<\/p>\n<p>????Mysql&gt; grant all privileges on *.* to root@&#8217;%&#8217;;<br \/>\n????Query OK, 0 rows affected (0.04 sec)<\/p>\n<p>????Mysql&gt; flush privileges;<br \/>\n????Query OK, 0 rows affected (0.01 sec)<\/p>\n<p>??8. Create a soft link (non-essential)<\/p>\n<p>Ln -s \/usr\/local\/mysql\/bin\/* \/usr\/local\/bin\/<\/p>\n<p>Mysql -h 127.0.0.1 -P 3306 -uroot -p123456 -e &#8220;select version();&#8221;<br \/>\nmysql: [Warning] Using a password on the command line interface can be insecure.<br \/>\n+&#8212;&#8212;&#8212;- -+<br \/>\n| version() |<br \/>\n+&#8212;&#8212;&#8212;&#8211;+<br \/>\n| 8.0.11 |<br \/>\n+&#8212;&#8212;&#8212;&#8211;+<\/p>\n<p>??9. Add to start (non-essential)<\/p>\n<p>Cp support-files\/mysql.server \/etc\/init.d\/mysql.server<\/p>\n<p>Hereby explain: MySQL official recommended to use binary installation.\u00a0(The following figure is a screenshot of the official document)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Full understanding of the new features of MySQL 8.0 <\/p>\n<p>First, the function added in MySQL 8.0<\/p>\n<p>1, the new system dictionary table<\/p>\n<p>Integrated transaction data dictionary for storing information about database objects, all metadata is stored using the InnoDB engine<\/p>\n<p>2, support for DDL atomic operations<\/p>\n<p>The DDL of the InnoDB table supports transaction integrity, [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7530"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7530"}],"version-history":[{"count":4,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7530\/revisions"}],"predecessor-version":[{"id":7534,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7530\/revisions\/7534"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}