Mysql:Changes in MySQL 5.6.6 (2012-08-07, Milestone 9):Group-Commit等等:重大变化版本!
This is a milestone release, for use at your own risk. Upgrades between milestone releases (or from a milestone release to a GA release) are not supported. Significant development changes take place in milestone releases and you may encounter compatibility issues, such as data format changes that require attention in addition to the usual procedure of running mysql_upgrade. For example, you may find it necessary to dump your data with mysqldump before the upgrade and reload it afterward. (Making a backup before the upgrade is a prudent precaution in any case.)
-
Performance: The server now implements group commit for the binary log: Multiple commits are grouped in memory, then written and flushed to disk as a group rather than individually. This reduces the number of writes and flushes, improving performance of binary logging. Group commit works for all storage engines.
InnoDBimplements some optimizations to take advantage of group commit capability.These system variables were added in conjunction with group commit:
-
binlog_order_commits: Whether to commit transactions in the same order they are written to the binary log or permit them to be committed in parallel. -
binlog_max_flush_queue_time: How long in microseconds to keep reading transactions from the flush queue before proceeding with the group commit. -
innodb_flush_log_at_timeout: Write and flush logs everyNseconds.
-
-
This MySQL release implements changes to the default values of several server parameters. The motivation for these changes is to provide better out-of-box performance and to reduce the need for database administrators to change settings manually. These changes are subject to revision in future releases as we gain feedback. (See Changes to Server Defaults.)
In some cases, a parameter has a different fixed default value. In other cases, the server autosizes a parameter at startup using a formula based on other related parameters or server host configuration, rather than using a fixed value. For example, the setting for
back_logis its previous default of 50, adjusted up by an amount proportional to the value ofmax_connections. The idea behind autosizing is that when the server has information available to make a decision about a parameter setting likely to be better than a fixed default, it will.The following table summarizes changes to defaults. For variables that are autosized, the main variable description provides additional detail about the sizing algorithm. See Server System Variables, and InnoDB Startup Options and System Variables. Any of these default settings can be overridden by specifying an explicit value at server startup.
With regard to compatibility with previous releases, the most important changes are:
-
innodb_file_per_tableis enabled (previously disabled) -
innodb_checksum_algorithmisCRC32(previouslyINNODB) -
binlog_checksumisCRC32(previouslyNONE)
Therefore, if you are upgrading an existing MySQL installation, have not already changed the values of these parameters from their previous defaults, and backward compatibility is a concern, you may want to explicitly set these parameters to their previous defaults. For example, put these lines in the server option file:
[mysqld] innodb_file_per_table=0 innodb_checksum_algorithm=INNODB binlog_checksum=NONE
Those settings preserve compatibility as follows:
-
With the new default of
innodb_file_per_tableenabled,ALTER TABLEoperations following an upgrade will moveInnoDBtables that are in the system tablespace to individual.ibdfiles. Usinginnodb_file_per_table=0will prevent this from happening. -
Setting
innodb_checksum_algorithm=INNODBpermits binary downgrades after upgrading to this release. With a setting ofCRC32, InnoDB would use checksumming that older MySQL versions cannot use. -
With
binlog_checksum=NONE, the server can be used as a replication master without causing failure of older slaves that do not understand binary log checksums.
-
-
The Performance Schema is now enabled by default (the
performance_schemasystem variable is enabled by default). To disable it, setperformance_schema=offat server startup.In addition, the Performance Schema now automatically sizes the values of several of its parameters at server startup if they are not set explicitly. For example, it sizes the parameters that control the sizes of the events waits tables this way. To see which parameters are sized under this policy, use mysqld --verbose --help and look for those with a default value of −1, or see Performance Schema System Variables.
For each autosized parameter that is not set at server startup (or is set to −1), the Performance Schema determines how to set its value based on the value of the following system values, which are considered as “hints” about how you have configured your MySQL server:
max_connections open_files_limit table_definition_cache table_open_cache
To override autosizing for a given parameter, set it a value other than −1 at startup. In this case, the Performance Schema assigns it the specified value.
At runtime,
SHOW VARIABLESdisplays the actual values that autosized parameters were set to.If the Performance Schema is disabled, its autosized parameters remain set to −1 and
SHOW VARIABLESdisplays −1.
-
These security improvements were implemented:
-
MySQL now provides a method for storing authentication credentials encrypted in an option file named
.mylogin.cnf. To create the file, use the mysql_config_editor utility. The file can be read later by MySQL client programs to obtain authentication credentials for connecting to a MySQL server. mysql_config_editor writes the.mylogin.cnffile using encryption so the credentials are not stored as clear text, and its contents when decrypted by client programs are used only in memory. In this way, passwords can be stored in a file in non-cleartext format and used later without ever needing to be exposed on the command line or in an environment variable. For more information, see mysql_config_editor — MySQL Configuration Utility.The
.mylogin.cnffile can contain multiple sets of options, known as “login paths.” This makes it easy to set up multiple “personalities” for connecting to different MySQL servers. Any of these can be selected by name later using the--login-pathoption when you invoke a client program. See Command-Line Options that Affect Option-File Handling. -
MySQL now supports stronger encryption for user account passwords, available through an authentication plugin named
sha256_passwordthat implements SHA-256 password hashing. This plugin is built in, so it is always available and need not be loaded explicitly. For more information, including instructions for creating accounts that use SHA-256 passwords, see SHA-256 Pluggable Authentication.Other changes associated with the introduction of the
sha256_passwordplugin:-
The
old_passwordssystem variable previously permitted values of 1 or 0 to control whether “old” or “new” MySQL native password hashing was used by theCREATE USERandGRANTstatements and thePASSWORD()function. Nowold_passwordspermits a value of 2 to select use of SHA-256 password hashing.NotePreviously,
old_passwordspermitted values ofOFForONas synonyms for 0 or 1. That is no longer true. -
SHA-256 password hashing (
old_passwords=2) uses a random salt value, which makes the result fromPASSWORD()nondeterministic. Consequently, statements that use this function are no longer safe for statement-based replication and cannot be stored in the query cache. -
If MySQL is built with OpenSSL, RSA encryption can be used to transmit passwords during the client connection process. The
sha256_password_private_key_pathandsha256_password_public_key_pathsystem variables permit the private and public key files to be named on the server side. TheRsa_public_keystatus variable displays the public key value. The mysql and mysqltest clients support a--server-public-keyoption permitting the public key file to be specified explicitly when connecting to the server. (This option is implemented through a newMYSQL_SERVER_PUBLIC_KEYoption to themysql_options()C API function.)
MySQL Connector support: Connectors that use the C client library should work with
sha256_passwordwith no changes. Connectors that implement the authentication process for themselves must be updated to account for changes in the client/server protocol. -
-
The server now has a
--default-authentication-pluginoption to specify the default plugin to associate with new accounts for which no plugin is named explicitly. Permitted values aremysql_native_password(use MySQL native passwords; this is the default value) andsha256_password(use SHA-256 passwords). This option also changes the initialold_passwordsvalue to be consistent with the password hashing method required by the default plugin, if necessary.NoteIf you use this option to change the default authentication method to a value other than
mysql_native_password, clients older than MySQL 5.5.7 will no longer be able to connect because they will not understand the change to the authentication protocol. -
The
mysql.usertable now has apassword_expiredcolumn to enable DBAs to expire account passwords and require users to reset their password. The defaultpassword_expiredvalue is'N', but can be set to'Y'with the newALTER USERstatement. After an account's password has been expired, all operations performed by the account in subsequent connections to the server result in an error until the user issues aSET PASSWORDstatement to establish a new account password. For more information, see ALTER USER Statement, and Server Handling of Expired Passwords.If you upgrade to this MySQL release from an earlier version, you must run mysql_upgrade (and restart the server) to incorporate this change into the
mysqldatabase.CautionUpdate:
ALTER USERalso set thePasswordcolumn to the empty string, so do not use this statement in 5.6.6. This problem has been fixed in MySQL 5.6.7. -
MySQL now has provision for checking password security:
-
In statements that assign a password supplied as a cleartext value, the value is checked against the current password policy and rejected if it is weak (the statement returns an
ER_NOT_VALID_PASSWORDerror). This affects theCREATE USER,GRANT, andSET PASSWORDstatements. Passwords given as arguments to thePASSWORD()andOLD_PASSWORD()functions are checked as well. -
The strength of potential passwords can be assessed using the new
VALIDATE_PASSWORD_STRENGTH()SQL function, which takes a password argument and returns an integer from 0 (weak) to 100 (strong).
Both capabilities are implemented by the
validate_passwordplugin. If the plugin is not installed, the affected statements andPASSWORD()andOLD_PASSWORD()work as before (no password checking), andVALIDATE_PASSWORD_STRENGTH()always returns 0.The
validate_passwordplugin also implements a set of system variables corresponding to the parameters that control password checking. If the plugin is installed, you can modify these variables to configure the password policy.The
validate_passwordplugin is written using the MySQL plugin API, which has been extended to support writing password-validation plugins.For more information, see The Password Validation Plugin. For information about writing password-checking plugins, see Writing Password-Validation Plugins.
-
-
mysql_upgrade now produces a warning if it finds user accounts with passwords hashed with the older pre-4.1 hashing method. Such accounts should be updated to use more secure password hashing. See Password Hashing in MySQL
(Bug #65461, Bug #14136939)
-
-
For the
WITH_SSLCMake option,nois no longer a permitted value or the default value. The default is nowbundled. Consequently, MySQL now is always built with SSL support.
-
Incompatible Change: It is now explicitly disallowed to assign the value
DEFAULTto stored procedure or function parameters or stored program local variables (for example with aSETstatement). This was not previously supported, or documented as permitted, but is flagged as an incompatible change in case existing code inadvertently used this construct. It remains permissible to assignvar_name= DEFAULTDEFAULTto system variables, as before, but assigningDEFAULTto parameters or local variables now results in a syntax error.After an upgrade to MySQL 5.6.6 or later, existing stored programs that use this construct produce a syntax error when invoked. If a mysqldump file from 5.6.5 or earlier is loaded into 5.6.6 or later, the load operation fails and affected stored program definitions must be changed.
-
Incompatible Change: The
--safe-modeserver option has been removed. -
Important Change; Partitioning: MySQL nows supports partition lock pruning, which allows for many DDL and DML statements against partitioned tables using
MyISAM(or another storage engine that employs table-level locking) to lock only those partitions directly affected by the statement. These statements include (but are not limited to) manySELECT,SELECT ... PARTITION,UPDATE,REPLACE,INSERT, and other statements. This enhancement improves especially the performance of many such statements when used with tables having many (32 or more) partitions. For a complete list of affected statements with particulars, and other information, see Partitioning and Locking. (Bug #37252, Bug #11748732) -
Important Change; Replication: It is now possible, in the event that a multithreaded slave fails while running with the
--relay-log-recoveryoption, to switch it safely to single-threaded mode despite the presence of any gaps with unprocessed transactions in the relay log. To accomplish this, you can now useSTART SLAVE [SQL_THREAD] UNTIL SQL_AFTER_MTS_GAPSto cause the slave SQL threads to run until no more such gaps are found in the relay log. Once this statement has completed, you can change theslave_parallel_workerssystem variable, and (if necessary) issue aCHANGE MASTER TOstatement before restarting the slave. (Bug #13893363)References: See also: Bug #13893310.
-
Important Change; Replication:
INSERT ON DUPLICATE KEY UPDATEis now marked as unsafe for statement-based replication if the target table has more than one primary or unique key. For more information, see Determination of Safe and Unsafe Statements in Binary Logging. (Bug #58637, Bug #11765650, Bug #13038678) -
Important Change; Replication: The
SHOW BINARY LOGSstatement (and its equivalentSHOW MASTER LOGS) may now be executed by a user with theREPLICATION CLIENTprivilege. (Formerly, theSUPERprivilege was necessary to use either form of this statement.) -
Important Change:
INSERT DELAYEDis now deprecated, and will be removed in a future release. UseINSERT(withoutDELAYED) instead. (Bug #13985071) -
Important Change: In MySQL, the
TIMESTAMPdata type differs in nonstandard ways from other data types:-
TIMESTAMPcolumns not explicitly declared with theNULLattribute are assigned theNOT NULLattribute. (Columns of other data types permitNULLvalues if not explicitly declared with theNOT NULLattribute.) Setting such a column toNULLsets it to the current timestamp. -
The first
TIMESTAMPcolumn in a table, if not declared with theNULLattribute or an explicitDEFAULTorON UPDATEattribute, is automatically assigned theDEFAULT CURRENT_TIMESTAMPandON UPDATE CURRENT_TIMESTAMPattributes. -
TIMESTAMPcolumns following the first one, if not declared with theNULLattribute or an explicitDEFAULTattribute, are automatically assignedDEFAULT '0000-00-00 00:00:00'(the “zero” timestamp). For inserted rows that specify no explicit value for such a column, the column is assigned'0000-00-00 00:00:00'and no warning occurs.
Those nonstandard behaviors remain the default for
TIMESTAMPbut now are deprecated and this warning appears at startup:[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
As indicated by the warning, to turn off the nonstandard behaviors, enable the new
explicit_defaults_for_timestampsystem variable at server startup. With this variable enabled, the server handlesTIMESTAMPas follows instead:-
TIMESTAMPcolumns permitNULLvalues if not explicitly declared with theNOT NULLattribute. Setting such a column toNULLsets it toNULL, not the current timestamp. -
No
TIMESTAMPcolumn is assigned theDEFAULT CURRENT_TIMESTAMPorON UPDATE CURRENT_TIMESTAMPattributes automatically. Those attributes must be explicitly specified. -
TIMESTAMPcolumns declared asNOT NULLand without an explicitDEFAULTattribute are treated as having no default value. For inserted rows that specify no explicit value for such a column, the result depends on the SQL mode. If strict SQL mode is enabled, an error occurs. If strict SQL mode is not enabled, the column is assigned the implicit default of'0000-00-00 00:00:00'and a warning occurs. This is similar to how MySQL treats other temporal types such asDATETIME.
To upgrade servers used for replication, upgrade the slaves first, then the master. Replication between the master and its slaves should work provided that all use the same value of
explicit_defaults_for_timestamp:-
Bring down the slaves, upgrade them, configure them with the desired value of
explicit_defaults_for_timestamp, and bring them back up.The slaves will recognize from the format of the binary logs received from the master that the master is older (predates the introduction of
explicit_defaults_for_timestamp) and that operations onTIMESTAMPcolumns coming from the master use the oldTIMESTAMPbehavior. -
Bring down the master, upgrade it, and configure it with the same
explicit_defaults_for_timestampvalue used on the slaves, and bring it back up.
(Bug #63034, Bug #13344629, Bug #55131, Bug #11762529)
-
-
Important Change: The
YEAR(2)data type is now deprecated because it is problematic.YEAR(2)columns in existing tables are treated as before, butYEAR(2)in new or altered tables are converted toYEAR(4). Support forYEAR(2)will be removed entirely in a future MySQL release. For more information, see 2-Digit YEAR(2) Limitations and Migrating to 4-Digit YEAR. -
Performance; InnoDB: Many DDL operations on
InnoDBtables can now be performed online, without making the tables unavailable for queries. Some operations, such as creating or dropping indexes, even allow DML statements (INSERT,UPDATE,DELETE) on the table while the operation is in progress. A single online DDL operation can also take the place of a sequence of statements, such as severalDROP INDEXstatements,ALTER TABLE ... ADD COLUMN, and then severalCREATE INDEXstatements. See InnoDB and Online DDL for full details.An additional effect of this change occurs for consistent-read transactions that try to reread data from a table which was changed by
ALTER TABLEin another session. Instead of receiving an empty set, the transaction will receive an error (ER_TABLE_DEF_CHANGED, “Table definition has changed, please retry transaction”). (Bug #58368, Bug #11765404, Bug #11872643, Bug #12325508, Bug #11765266, Bug #60689) -
Performance; InnoDB: The persistent statistics feature for
InnoDBtables is now enabled by default, and can be controlled at the level of individual tables. This feature involves the configuration optionsinnodb_stats_persistent,innodb_stats_auto_recalc, andinnodb_stats_persistent_sample_pages, and the clausesSTATS_PERSISTENT,STATS_AUTO_RECALC, andSTATS_SAMPLE_PAGESof theCREATE TABLEandALTER TABLEstatements. See Configuring Persistent Optimizer Statistics Parameters for usage details. -
Performance; InnoDB: The MySQL server now includes the widely used memcached in-memory caching system, and a plugin that allows fast NoSQL-style access to
InnoDBtables through the memcached protocol. This access method avoids the overhead of SQL parsing and constructing a query optimization plan. You can store the underlying data in a singleInnoDBtable, or spread it across multiple tables. You can read and write data through bothmemcachedand SQL. For example, you can do fast single-key lookups through memcachedgetcalls, and do statistical reports across all the data through SQL.Several configuration options let you fine-tune this system, in particular to balance raw performance against durability and consistency of data. The main new configuration options are
daemon_memcached_option,daemon_memcached_r_batch_size,daemon_memcached_w_batch_size,innodb_api_trx_level,innodb_api_enable_mdl, andinnodb_api_enable_binlog.See InnoDB memcached Plugin for full details.
-
InnoDB: For systems with constant heavy workloads, or workloads that fluctuate widely, several new configuration options let you fine-tune the flushing behavior for
InnoDBtables:innodb_adaptive_flushing_lwm,innodb_max_dirty_pages_pct_lwm,innodb_max_io_capacity(changed in subsequent point releases toinnodb_io_capacity_max), andinnodb_flushing_avg_loops. These options feed into an improved formula used by theinnodb_adaptive_flushingoption. See Configuring Buffer Pool Flushing. -
InnoDB:
InnoDBtables now support the notion of “transportable tablespaces”, allowing.ibdfiles to be exported from a running MySQL instance and imported into another running instance. TheFOR EXPORTclause of theFLUSH TABLESstatement writes any unsaved changes fromInnoDBmemory buffers to the.ibdfile. After copying the.ibdfile and a separate metadata file to the other server, you can use theDISCARD TABLESPACEandIMPORT TABLESPACEclauses of theALTER TABLEstatement to bring the table data into a different MySQL instance.For more information, see Importing InnoDB Tables.
-
InnoDB:
InnoDBnow supports theDATA DIRECTORY='clause of thedirectory'CREATE TABLEstatement, which permits creating tables outside the data directory. For more information, see Creating Tables Externally. -
Replication: The
STOP SLAVEoptionSQL_BEFORE_GTIDSdid not function correctly, and theSQL_AFTER_GTIDSoption for the same statement did not function at all. (Bug #13810456) -
Replication: Added the
slave_rows_search_algorithmssystem variable for mysqld, which determines the search algorithms used for finding matches for slave updates whenslave_allow_batchingis enabled, including whether or not table or index hashing is used with searches employing a primary or unique key, some other key, or no key. -
The Performance Schema has a new system variable,
performance_schema_session_connect_attrs_size, and new status variable,Performance_schema_session_connect_attrs_lost. The system variable is the amount of preallocated memory per thread reserved to hold connection attribute key/value pairs. If the aggregate size of connection attribute data sent by a client is larger than this amount, the Performance Schema truncates the attribute data and increments the status variable. See Performance Schema Connection Attribute Tables. (Bug #14076427) -
yaSSL was upgraded from version 1.7.2 to 2.1.4. (Bug #13713205)
References: See also: Bug #13706828.
-
The optimizer's cost model for disk-sweep Multi-Read Range (DS-MRR) has been improved. The improved cost model makes it more likely that DSMRR will be used for queries that read much data from disk.
-
Previously, the default value for the
bind_addresssystem variable was0.0.0.0, which causes the server to accept TCP/IP connections on all server host IPv4 interfaces. To make it easier to use IPv6 connections without special configuration, the defaultbind_addressvalue now is*. This is similar to0.0.0.0, but causes the server to also accept TCP/IP connections on all IPv6 interfaces if the server host supports IPv6. (Another way to accept IPv4 and IPv6 connections is by usingbind_address=::, but in this case an error occurs if the server host does not support IPv6.) -
It is now possible for client programs to pass connection attributes to the server in the form of key/value pairs. Attributes are manipulated using the
MYSQL_OPT_CONNECT_ATTR_RESETandMYSQL_OPT_CONNECT_ATTR_DELETEoptions for themysql_options()C API function, and theMYSQL_OPT_CONNECT_ATTR_ADDoption for the newmysql_options4()function. Connection attributes are exposed through thesession_connect_attrsandsession_account_connect_attrsPerformance Schema tables.If you upgrade to this MySQL release from an earlier version, you must run mysql_upgrade (and restart the server) to incorporate these changes into the
performance_schemadatabase.For more information, see C API Function Descriptions, and MySQL Performance Schema.
-
Previously, for semijoin processing the outer query specification was limited to simple table scans or inner joins using comma syntax, and view references were not possible. Now outer join and inner join syntax is permitted in the outer query specification, and the restriction that table references must be base tables has been lifted.
-
To improve scalability by reducing contention among sessions for the global lock on the open tables cache, the cache now can be partitioned into several smaller cache instances. A session now need lock only one instance to access it for DML statements. This segments cache access among instances, permitting higher performance for operations that need to use the cache when many there are many sessions accessing tables. (DDL statements still require a lock on the entire cache, but such statements are much less frequent than DML statements.)
A new system variable,
table_open_cache_instances, permits control over the number of cache instances. Each instance has a size oftable_open_cache/table_open_cache_instances. By default, the number of instances is 1.Three new status variables provide information about the operation of the open tables cache.
Table_open_cache_hitsandTable_open_cache_missesindicate the number of hits and misses or lookups in the cache.Table_open_cache_overflowsindicates how many times, after a table is opened or closed, an instance has an unused entry and the size of the instance is larger thantable_open_cache/table_open_cache_instances. -
The generic “procedure API” has been removed from the server. This was formerly present as a means of writing server procedures, but went unused except for
PROCEDURE ANALYSE(). Removing the interface simplifies aspects of the internal procedure representation that were related to code no longer in the server but had a negative effect on its operation, in the sense that these aspects hindered the ability of the optimizer to perform better on more common query types. In addition, this code hindered future optimizer development and its removal will have benefit that development.PROCEDURE ANALYSE()remains available, but is no longer implemented using a public interface. (For information, see Using PROCEDURE ANALYSE.) One consequence of removing the procedure interface is thatEXPLAIN SELECT ... PROCEDURE ANALYSE()now works where previously it produced an error.
浙公网安备 33010602011771号