MySQL 5.6 Reference Manual Including NDB Cluster 7.3 7.4 Guide Ref En
User Manual:
Open the PDF directly: View PDF .
Page Count: 4534
MySQL 5.6 Reference Manual
Including MySQL NDB Cluster 7.3-7.4 Reference Guide
Abstract
This is the MySQL™ Reference Manual. It documents MySQL 5.6 through 5.6.43, as well as NDB Cluster releases
based on versions 7.3 and 7.4 of NDB through 5.6.42-ndb-7.3.24 and 5.6.42-ndb-7.4.23, respectively. It may include
documentation of features of MySQL versions that have not yet been released. For information about which versions
have been released, see the MySQL 5.6 Release Notes.
MySQL 5.6 features.
This manual describes features that are not included in every edition of MySQL 5.6; such
features may not be included in the edition of MySQL 5.6 licensed to you. If you have any questions about the
features included in your edition of MySQL 5.6, refer to your MySQL 5.6 license agreement or contact your Oracle
sales representative.
For notes detailing the changes in each release, see the MySQL 5.6 Release Notes.
For legal information, including licensing information, see the Preface and Legal Notices.
For help with using MySQL, please visit either the MySQL Forums or MySQL Mailing Lists, where you can discuss
your issues with other MySQL users.
Document generated on: 2018-11-02 (revision: 59809)
Table of Contents
Preface and Legal Notices .............................................................................................................. xxv
1 General Information ......................................................................................................................... 1
1.1 About This Manual ............................................................................................................... 2
1.2 Typographical and Syntax Conventions ................................................................................. 3
1.3 Overview of the MySQL Database Management System ........................................................ 4
1.3.1 What is MySQL? ....................................................................................................... 4
1.3.2 The Main Features of MySQL .................................................................................... 6
1.3.3 History of MySQL ...................................................................................................... 9
1.4 What Is New in MySQL 5.6 .................................................................................................. 9
1.5 MySQL Information Sources ............................................................................................... 22
1.5.1 MySQL Websites ..................................................................................................... 22
1.5.2 MySQL Mailing Lists ................................................................................................ 22
1.5.3 MySQL Community Support at the MySQL Forums ................................................... 24
1.5.4 MySQL Community Support on Internet Relay Chat (IRC) .......................................... 25
1.5.5 MySQL Enterprise .................................................................................................... 25
1.6 How to Report Bugs or Problems ........................................................................................ 25
1.7 MySQL Standards Compliance ............................................................................................ 30
1.7.1 MySQL Extensions to Standard SQL ........................................................................ 31
1.7.2 MySQL Differences from Standard SQL .................................................................... 34
1.7.3 How MySQL Deals with Constraints ......................................................................... 36
1.8 Credits ............................................................................................................................... 39
1.8.1 Contributors to MySQL ............................................................................................. 39
1.8.2 Documenters and translators .................................................................................... 44
1.8.3 Packages that support MySQL ................................................................................. 45
1.8.4 Tools that were used to create MySQL ..................................................................... 46
1.8.5 Supporters of MySQL .............................................................................................. 46
2 Installing and Upgrading MySQL .................................................................................................... 49
2.1 General Installation Guidance ............................................................................................. 51
2.1.1 Which MySQL Version and Distribution to Install ....................................................... 51
2.1.2 How to Get MySQL ................................................................................................. 53
2.1.3 Verifying Package Integrity Using MD5 Checksums or GnuPG ................................... 53
2.1.4 Installation Layouts .................................................................................................. 67
2.1.5 Compiler-Specific Build Characteristics ..................................................................... 67
2.2 Installing MySQL on Unix/Linux Using Generic Binaries ........................................................ 67
2.3 Installing MySQL on Microsoft Windows .............................................................................. 70
2.3.1 MySQL Installation Layout on Microsoft Windows ...................................................... 73
2.3.2 Choosing an Installation Package ............................................................................. 74
2.3.3 MySQL Installer for Windows ................................................................................... 75
2.3.4 MySQL Notifier ........................................................................................................ 97
2.3.5 Installing MySQL on Microsoft Windows Using a noinstall ZIP Archive ................. 109
2.3.6 Troubleshooting a Microsoft Windows MySQL Server Installation .............................. 117
2.3.7 Windows Postinstallation Procedures ...................................................................... 119
2.3.8 Upgrading MySQL on Windows .............................................................................. 121
2.4 Installing MySQL on OS X ................................................................................................ 123
2.4.1 General Notes on Installing MySQL on OS X .......................................................... 123
2.4.2 Installing MySQL on OS X Using Native Packages .................................................. 124
2.4.3 Installing a MySQL Launch Daemon ....................................................................... 129
2.4.4 Installing and Using the MySQL Preference Pane .................................................... 131
2.5 Installing MySQL on Linux ................................................................................................ 136
2.5.1 Installing MySQL on Linux Using the MySQL Yum Repository .................................. 137
2.5.2 Replacing a Third-Party Distribution of MySQL Using the MySQL Yum Repository ..... 141
iii
MySQL 5.6 Reference Manual
2.5.3 Installing MySQL on Linux Using the MySQL APT Repository ...................................
2.5.4 Installing MySQL on Linux Using the MySQL SLES Repository .................................
2.5.5 Installing MySQL on Linux Using RPM Packages from Oracle ..................................
2.5.6 Installing MySQL on Linux Using Debian Packages from Oracle ...............................
2.5.7 Installing MySQL on Linux from the Native Software Repositories .............................
2.5.8 Deploying MySQL on Linux with Docker ..................................................................
2.5.9 Installing MySQL on Linux with Juju .......................................................................
2.6 Installing MySQL Using Unbreakable Linux Network (ULN) .................................................
2.7 Installing MySQL on Solaris ..............................................................................................
2.7.1 Installing MySQL on Solaris Using a Solaris PKG ....................................................
2.8 Installing MySQL on FreeBSD ...........................................................................................
2.9 Installing MySQL from Source ...........................................................................................
2.9.1 MySQL Layout for Source Installation .....................................................................
2.9.2 Installing MySQL Using a Standard Source Distribution ............................................
2.9.3 Installing MySQL Using a Development Source Tree ...............................................
2.9.4 MySQL Source-Configuration Options .....................................................................
2.9.5 Dealing with Problems Compiling MySQL ................................................................
2.9.6 MySQL Configuration and Third-Party Tools ............................................................
2.10 Postinstallation Setup and Testing ...................................................................................
2.10.1 Initializing the Data Directory ................................................................................
2.10.2 Starting the Server ...............................................................................................
2.10.3 Testing the Server ................................................................................................
2.10.4 Securing the Initial MySQL Accounts ....................................................................
2.10.5 Starting and Stopping MySQL Automatically ..........................................................
2.11 Upgrading or Downgrading MySQL ..................................................................................
2.11.1 Upgrading MySQL ................................................................................................
2.11.2 Downgrading MySQL ...........................................................................................
2.11.3 Rebuilding or Repairing Tables or Indexes ............................................................
2.11.4 Copying MySQL Databases to Another Machine ....................................................
2.12 Perl Installation Notes .....................................................................................................
2.12.1 Installing Perl on Unix ..........................................................................................
2.12.2 Installing ActiveState Perl on Windows ..................................................................
2.12.3 Problems Using the Perl DBI/DBD Interface ..........................................................
3 Tutorial ........................................................................................................................................
3.1 Connecting to and Disconnecting from the Server ..............................................................
3.2 Entering Queries ...............................................................................................................
3.3 Creating and Using a Database ........................................................................................
3.3.1 Creating and Selecting a Database .........................................................................
3.3.2 Creating a Table ....................................................................................................
3.3.3 Loading Data into a Table ......................................................................................
3.3.4 Retrieving Information from a Table ........................................................................
3.4 Getting Information About Databases and Tables ...............................................................
3.5 Using mysql in Batch Mode ..............................................................................................
3.6 Examples of Common Queries ..........................................................................................
3.6.1 The Maximum Value for a Column .........................................................................
3.6.2 The Row Holding the Maximum of a Certain Column ...............................................
3.6.3 Maximum of Column per Group ..............................................................................
3.6.4 The Rows Holding the Group-wise Maximum of a Certain Column ............................
3.6.5 Using User-Defined Variables .................................................................................
3.6.6 Using Foreign Keys ................................................................................................
3.6.7 Searching on Two Keys .........................................................................................
3.6.8 Calculating Visits Per Day ......................................................................................
3.6.9 Using AUTO_INCREMENT .....................................................................................
3.7 Using MySQL with Apache ...............................................................................................
iv
143
144
144
148
150
154
161
161
162
162
163
164
166
166
171
173
188
189
190
190
194
196
198
203
204
204
217
222
224
225
225
226
227
229
229
230
234
235
235
237
238
252
253
255
255
256
256
257
257
258
259
260
260
263
MySQL 5.6 Reference Manual
4 MySQL Programs ........................................................................................................................
4.1 Overview of MySQL Programs ..........................................................................................
4.2 Using MySQL Programs ...................................................................................................
4.2.1 Invoking MySQL Programs .....................................................................................
4.2.2 Connecting to the MySQL Server ...........................................................................
4.2.3 Specifying Program Options ...................................................................................
4.2.4 Using Options on the Command Line .....................................................................
4.2.5 Program Option Modifiers .......................................................................................
4.2.6 Using Option Files .................................................................................................
4.2.7 Command-Line Options that Affect Option-File Handling ..........................................
4.2.8 Using Options to Set Program Variables .................................................................
4.2.9 Option Defaults, Options Expecting Values, and the = Sign ......................................
4.2.10 Setting Environment Variables ..............................................................................
4.3 MySQL Server and Server-Startup Programs .....................................................................
4.3.1 mysqld — The MySQL Server ...............................................................................
4.3.2 mysqld_safe — MySQL Server Startup Script ......................................................
4.3.3 mysql.server — MySQL Server Startup Script ....................................................
4.3.4 mysqld_multi — Manage Multiple MySQL Servers ...............................................
4.4 MySQL Installation-Related Programs ................................................................................
4.4.1 comp_err — Compile MySQL Error Message File ..................................................
4.4.2 mysqlbug — Generate Bug Report .......................................................................
4.4.3 mysql_install_db — Initialize MySQL Data Directory .........................................
4.4.4 mysql_plugin — Configure MySQL Server Plugins ..............................................
4.4.5 mysql_secure_installation — Improve MySQL Installation Security ................
4.4.6 mysql_tzinfo_to_sql — Load the Time Zone Tables .........................................
4.4.7 mysql_upgrade — Check and Upgrade MySQL Tables .........................................
4.5 MySQL Client Programs ...................................................................................................
4.5.1 mysql — The MySQL Command-Line Tool ............................................................
4.5.2 mysqladmin — Client for Administering a MySQL Server .......................................
4.5.3 mysqlcheck — A Table Maintenance Program ......................................................
4.5.4 mysqldump — A Database Backup Program ..........................................................
4.5.5 mysqlimport — A Data Import Program ...............................................................
4.5.6 mysqlshow — Display Database, Table, and Column Information ............................
4.5.7 mysqlslap — Load Emulation Client .....................................................................
4.6 MySQL Administrative and Utility Programs .......................................................................
4.6.1 innochecksum — Offline InnoDB File Checksum Utility ..........................................
4.6.2 myisam_ftdump — Display Full-Text Index information ..........................................
4.6.3 myisamchk — MyISAM Table-Maintenance Utility ..................................................
4.6.4 myisamlog — Display MyISAM Log File Contents ..................................................
4.6.5 myisampack — Generate Compressed, Read-Only MyISAM Tables ........................
4.6.6 mysql_config_editor — MySQL Configuration Utility .........................................
4.6.7 mysqlaccess — Client for Checking Access Privileges ..........................................
4.6.8 mysqlbinlog — Utility for Processing Binary Log Files ..........................................
4.6.9 mysqldumpslow — Summarize Slow Query Log Files ............................................
4.6.10 mysqlhotcopy — A Database Backup Program ..................................................
4.6.11 mysql_convert_table_format — Convert Tables to Use a Given Storage
Engine ............................................................................................................................
4.6.12 mysql_find_rows — Extract SQL Statements from Files ....................................
4.6.13 mysql_fix_extensions — Normalize Table File Name Extensions ....................
4.6.14 mysql_setpermission — Interactively Set Permissions in Grant Tables ..............
4.6.15 mysql_waitpid — Kill Process and Wait for Its Termination ................................
4.6.16 mysql_zap — Kill Processes That Match a Pattern ..............................................
4.7 MySQL Program Development Utilities ..............................................................................
4.7.1 msql2mysql — Convert mSQL Programs for Use with MySQL ...............................
265
266
271
271
271
275
276
278
279
284
285
286
290
291
291
291
296
299
303
303
304
304
308
310
310
311
317
317
342
350
358
380
386
391
400
400
401
402
419
420
426
433
436
455
457
460
461
462
462
463
464
464
465
v
MySQL 5.6 Reference Manual
4.7.2 mysql_config — Display Options for Compiling Clients ........................................
4.7.3 my_print_defaults — Display Options from Option Files ....................................
4.7.4 resolve_stack_dump — Resolve Numeric Stack Trace Dump to Symbols .............
4.8 Miscellaneous Programs ...................................................................................................
4.8.1 perror — Explain Error Codes .............................................................................
4.8.2 replace — A String-Replacement Utility ................................................................
4.8.3 resolveip — Resolve Host name to IP Address or Vice Versa ..............................
4.9 MySQL Program Environment Variables ............................................................................
5 MySQL Server Administration ......................................................................................................
5.1 The MySQL Server ...........................................................................................................
5.1.1 Configuring the Server ...........................................................................................
5.1.2 Server Configuration Defaults .................................................................................
5.1.3 Server Option, System Variable, and Status Variable Reference ...............................
5.1.4 Server System Variable Reference .........................................................................
5.1.5 Server Status Variable Reference ...........................................................................
5.1.6 Server Command Options ......................................................................................
5.1.7 Server System Variables ........................................................................................
5.1.8 Using System Variables .........................................................................................
5.1.9 Server Status Variables ..........................................................................................
5.1.10 Server SQL Modes ..............................................................................................
5.1.11 IPv6 Support ........................................................................................................
5.1.12 MySQL Server Time Zone Support .......................................................................
5.1.13 Server-Side Help ..................................................................................................
5.1.14 Server Response to Signals .................................................................................
5.1.15 The Server Shutdown Process .............................................................................
5.2 The MySQL Data Directory ...............................................................................................
5.3 The mysql System Database .............................................................................................
5.4 MySQL Server Logs .........................................................................................................
5.4.1 Selecting General Query Log and Slow Query Log Output Destinations .....................
5.4.2 The Error Log ........................................................................................................
5.4.3 The General Query Log .........................................................................................
5.4.4 The Binary Log ......................................................................................................
5.4.5 The Slow Query Log ..............................................................................................
5.4.6 The DDL Log .........................................................................................................
5.4.7 Server Log Maintenance ........................................................................................
5.5 MySQL Server Plugins ......................................................................................................
5.5.1 Installing and Uninstalling Plugins ...........................................................................
5.5.2 Obtaining Server Plugin Information ........................................................................
5.5.3 MySQL Enterprise Thread Pool ..............................................................................
5.6 MySQL Server User-Defined Functions ..............................................................................
5.6.1 Installing and Uninstalling User-Defined Functions ...................................................
5.6.2 Obtaining User-Defined Function Information ...........................................................
5.7 Running Multiple MySQL Instances on One Machine ..........................................................
5.7.1 Setting Up Multiple Data Directories ........................................................................
5.7.2 Running Multiple MySQL Instances on Windows .....................................................
5.7.3 Running Multiple MySQL Instances on Unix ............................................................
5.7.4 Using Client Programs in a Multiple-Server Environment ..........................................
5.8 Tracing mysqld Using DTrace ...........................................................................................
5.8.1 mysqld DTrace Probe Reference ............................................................................
6 Security .......................................................................................................................................
6.1 General Security Issues ....................................................................................................
6.1.1 Security Guidelines ................................................................................................
6.1.2 Keeping Passwords Secure ....................................................................................
6.1.3 Making MySQL Secure Against Attackers ...............................................................
vi
465
467
468
469
469
469
470
471
473
474
474
476
479
515
535
547
584
688
703
722
731
734
740
740
741
742
743
745
746
748
750
752
763
765
766
767
768
772
773
779
779
780
781
782
783
786
787
788
789
809
810
810
812
820
MySQL 5.6 Reference Manual
6.1.4 Security-Related mysqld Options and Variables .......................................................
6.1.5 How to Run MySQL as a Normal User ...................................................................
6.1.6 Security Issues with LOAD DATA LOCAL ...............................................................
6.1.7 Client Programming Security Guidelines ..................................................................
6.2 The MySQL Access Privilege System ................................................................................
6.2.1 Privileges Provided by MySQL ...............................................................................
6.2.2 Grant Tables ..........................................................................................................
6.2.3 Specifying Account Names .....................................................................................
6.2.4 Access Control, Stage 1: Connection Verification .....................................................
6.2.5 Access Control, Stage 2: Request Verification .........................................................
6.2.6 When Privilege Changes Take Effect ......................................................................
6.2.7 Troubleshooting Problems Connecting to MySQL ....................................................
6.3 MySQL User Account Management ...................................................................................
6.3.1 User Names and Passwords ..................................................................................
6.3.2 Adding User Accounts ............................................................................................
6.3.3 Removing User Accounts .......................................................................................
6.3.4 Setting Account Resource Limits ............................................................................
6.3.5 Assigning Account Passwords ................................................................................
6.3.6 Password Expiration and Sandbox Mode ................................................................
6.3.7 Pluggable Authentication ........................................................................................
6.3.8 Proxy Users ...........................................................................................................
6.3.9 SQL-Based MySQL Account Activity Auditing ..........................................................
6.4 Using Encrypted Connections ............................................................................................
6.4.1 Configuring MySQL to Use Encrypted Connections ..................................................
6.4.2 Command Options for Encrypted Connections .........................................................
6.4.3 Creating SSL and RSA Certificates and Keys ..........................................................
6.4.4 OpenSSL Versus yaSSL ........................................................................................
6.4.5 Building MySQL with Support for Encrypted Connections .........................................
6.4.6 Encrypted Connection Protocols and Ciphers ..........................................................
6.4.7 Connecting to MySQL Remotely from Windows with SSH ........................................
6.5 Security Plugins ................................................................................................................
6.5.1 Authentication Plugins ............................................................................................
6.5.2 The Connection-Control Plugins ..............................................................................
6.5.3 The Password Validation Plugin .............................................................................
6.5.4 MySQL Enterprise Audit .........................................................................................
6.5.5 MySQL Enterprise Firewall .....................................................................................
7 Backup and Recovery .................................................................................................................
7.1 Backup and Recovery Types .............................................................................................
7.2 Database Backup Methods ...............................................................................................
7.3 Example Backup and Recovery Strategy ...........................................................................
7.3.1 Establishing a Backup Policy ..................................................................................
7.3.2 Using Backups for Recovery ..................................................................................
7.3.3 Backup Strategy Summary .....................................................................................
7.4 Using mysqldump for Backups ..........................................................................................
7.4.1 Dumping Data in SQL Format with mysqldump ........................................................
7.4.2 Reloading SQL-Format Backups .............................................................................
7.4.3 Dumping Data in Delimited-Text Format with mysqldump .........................................
7.4.4 Reloading Delimited-Text Format Backups ..............................................................
7.4.5 mysqldump Tips .....................................................................................................
7.5 Point-in-Time (Incremental) Recovery Using the Binary Log ................................................
7.5.1 Point-in-Time Recovery Using Event Times .............................................................
7.5.2 Point-in-Time Recovery Using Event Positions ........................................................
7.6 MyISAM Table Maintenance and Crash Recovery ..............................................................
7.6.1 Using myisamchk for Crash Recovery .....................................................................
822
823
824
825
826
827
834
839
841
844
846
847
851
852
853
855
855
857
859
862
864
869
871
872
874
877
884
884
885
887
887
888
916
923
929
957
971
972
975
977
978
980
980
981
981
982
983
984
985
987
989
989
990
990
vii
MySQL 5.6 Reference Manual
7.6.2 How to Check MyISAM Tables for Errors ................................................................ 991
7.6.3 How to Repair MyISAM Tables ............................................................................... 992
7.6.4 MyISAM Table Optimization ................................................................................... 994
7.6.5 Setting Up a MyISAM Table Maintenance Schedule ................................................ 995
8 Optimization ................................................................................................................................ 997
8.1 Optimization Overview ...................................................................................................... 998
8.2 Optimizing SQL Statements ............................................................................................ 1000
8.2.1 Optimizing SELECT Statements ............................................................................ 1000
8.2.2 Optimizing Subqueries, Derived Tables, and Views ................................................ 1041
8.2.3 Optimizing INFORMATION_SCHEMA Queries ...................................................... 1051
8.2.4 Optimizing Data Change Statements ..................................................................... 1056
8.2.5 Optimizing Database Privileges ............................................................................. 1058
8.2.6 Other Optimization Tips ........................................................................................ 1058
8.3 Optimization and Indexes ................................................................................................ 1058
8.3.1 How MySQL Uses Indexes ................................................................................... 1059
8.3.2 Primary Key Optimization ..................................................................................... 1060
8.3.3 Foreign Key Optimization ..................................................................................... 1060
8.3.4 Column Indexes ................................................................................................... 1060
8.3.5 Multiple-Column Indexes ...................................................................................... 1062
8.3.6 Verifying Index Usage .......................................................................................... 1063
8.3.7 InnoDB and MyISAM Index Statistics Collection ..................................................... 1063
8.3.8 Comparison of B-Tree and Hash Indexes .............................................................. 1065
8.3.9 Use of Index Extensions ....................................................................................... 1067
8.4 Optimizing Database Structure ........................................................................................ 1069
8.4.1 Optimizing Data Size ............................................................................................ 1069
8.4.2 Optimizing MySQL Data Types ............................................................................. 1071
8.4.3 Optimizing for Many Tables .................................................................................. 1073
8.4.4 Internal Temporary Table Use in MySQL ............................................................... 1074
8.5 Optimizing for InnoDB Tables .......................................................................................... 1076
8.5.1 Optimizing Storage Layout for InnoDB Tables ........................................................ 1076
8.5.2 Optimizing InnoDB Transaction Management ........................................................ 1077
8.5.3 Optimizing InnoDB Read-Only Transactions .......................................................... 1078
8.5.4 Optimizing InnoDB Redo Logging ......................................................................... 1079
8.5.5 Bulk Data Loading for InnoDB Tables ................................................................... 1079
8.5.6 Optimizing InnoDB Queries .................................................................................. 1080
8.5.7 Optimizing InnoDB DDL Operations ...................................................................... 1081
8.5.8 Optimizing InnoDB Disk I/O .................................................................................. 1081
8.5.9 Optimizing InnoDB Configuration Variables ............................................................ 1084
8.5.10 Optimizing InnoDB for Systems with Many Tables ................................................ 1085
8.6 Optimizing for MyISAM Tables ........................................................................................ 1085
8.6.1 Optimizing MyISAM Queries ................................................................................. 1085
8.6.2 Bulk Data Loading for MyISAM Tables .................................................................. 1087
8.6.3 Optimizing REPAIR TABLE Statements ................................................................ 1088
8.7 Optimizing for MEMORY Tables ...................................................................................... 1090
8.8 Understanding the Query Execution Plan ......................................................................... 1090
8.8.1 Optimizing Queries with EXPLAIN ......................................................................... 1090
8.8.2 EXPLAIN Output Format ...................................................................................... 1091
8.8.3 Extended EXPLAIN Output Format ....................................................................... 1104
8.8.4 Estimating Query Performance ............................................................................. 1106
8.9 Controlling the Query Optimizer ....................................................................................... 1107
8.9.1 Controlling Query Plan Evaluation ......................................................................... 1107
8.9.2 Switchable Optimizations ...................................................................................... 1108
8.9.3 Index Hints .......................................................................................................... 1111
8.10 Buffering and Caching ................................................................................................... 1113
viii
MySQL 5.6 Reference Manual
8.10.1 InnoDB Buffer Pool Optimization .........................................................................
8.10.2 The MyISAM Key Cache ....................................................................................
8.10.3 The MySQL Query Cache ..................................................................................
8.10.4 Caching of Prepared Statements and Stored Programs ........................................
8.11 Optimizing Locking Operations ......................................................................................
8.11.1 Internal Locking Methods ....................................................................................
8.11.2 Table Locking Issues ..........................................................................................
8.11.3 Concurrent Inserts ..............................................................................................
8.11.4 Metadata Locking ...............................................................................................
8.11.5 External Locking .................................................................................................
8.12 Optimizing the MySQL Server .......................................................................................
8.12.1 System Factors ..................................................................................................
8.12.2 Optimizing Disk I/O ............................................................................................
8.12.3 Using Symbolic Links .........................................................................................
8.12.4 Optimizing Memory Use .....................................................................................
8.12.5 Optimizing Network Use .....................................................................................
8.13 Measuring Performance (Benchmarking) ........................................................................
8.13.1 Measuring the Speed of Expressions and Functions ............................................
8.13.2 The MySQL Benchmark Suite .............................................................................
8.13.3 Using Your Own Benchmarks .............................................................................
8.13.4 Measuring Performance with performance_schema ..............................................
8.14 Examining Thread Information .......................................................................................
8.14.1 Thread Command Values ...................................................................................
8.14.2 General Thread States .......................................................................................
8.14.3 Delayed-Insert Thread States ..............................................................................
8.14.4 Query Cache Thread States ...............................................................................
8.14.5 Replication Master Thread States .......................................................................
8.14.6 Replication Slave I/O Thread States ....................................................................
8.14.7 Replication Slave SQL Thread States ..................................................................
8.14.8 Replication Slave Connection Thread States ........................................................
8.14.9 NDB Cluster Thread States ................................................................................
8.14.10 Event Scheduler Thread States .........................................................................
9 Language Structure ...................................................................................................................
9.1 Literal Values ..................................................................................................................
9.1.1 String Literals .......................................................................................................
9.1.2 Numeric Literals ...................................................................................................
9.1.3 Date and Time Literals .........................................................................................
9.1.4 Hexadecimal Literals ............................................................................................
9.1.5 Bit-Value Literals ..................................................................................................
9.1.6 Boolean Literals ...................................................................................................
9.1.7 NULL Values .......................................................................................................
9.2 Schema Object Names ...................................................................................................
9.2.1 Identifier Qualifiers ...............................................................................................
9.2.2 Identifier Case Sensitivity .....................................................................................
9.2.3 Mapping of Identifiers to File Names .....................................................................
9.2.4 Function Name Parsing and Resolution .................................................................
9.3 Keywords and Reserved Words .......................................................................................
9.4 User-Defined Variables ...................................................................................................
9.5 Expression Syntax ..........................................................................................................
9.6 Comment Syntax ............................................................................................................
10 Character Sets, Collations, Unicode ..........................................................................................
10.1 Character Sets and Collations in General .......................................................................
10.2 Character Sets and Collations in MySQL .......................................................................
10.2.1 Character Set Repertoire ....................................................................................
1113
1114
1118
1126
1127
1127
1130
1131
1132
1133
1134
1134
1134
1136
1139
1143
1147
1147
1148
1149
1149
1149
1150
1152
1159
1160
1160
1161
1162
1163
1163
1164
1165
1165
1165
1168
1168
1171
1173
1174
1174
1175
1177
1179
1181
1183
1187
1210
1214
1216
1219
1220
1221
1223
ix
MySQL 5.6 Reference Manual
10.2.2 UTF-8 for Metadata ............................................................................................
10.3 Specifying Character Sets and Collations .......................................................................
10.3.1 Collation Naming Conventions ............................................................................
10.3.2 Server Character Set and Collation .....................................................................
10.3.3 Database Character Set and Collation .................................................................
10.3.4 Table Character Set and Collation ......................................................................
10.3.5 Column Character Set and Collation ...................................................................
10.3.6 Character String Literal Character Set and Collation .............................................
10.3.7 The National Character Set ................................................................................
10.3.8 Character Set Introducers ...................................................................................
10.3.9 Examples of Character Set and Collation Assignment ..........................................
10.3.10 Compatibility with Other DBMSs ........................................................................
10.4 Connection Character Sets and Collations .....................................................................
10.5 Configuring Application Character Set and Collation .......................................................
10.6 Error Message Character Set ........................................................................................
10.7 Column Character Set Conversion .................................................................................
10.8 Collation Issues ............................................................................................................
10.8.1 Using COLLATE in SQL Statements ...................................................................
10.8.2 COLLATE Clause Precedence ............................................................................
10.8.3 Character Set and Collation Compatibility ............................................................
10.8.4 Collation Coercibility in Expressions ....................................................................
10.8.5 The binary Collation Compared to _bin Collations ................................................
10.8.6 Examples of the Effect of Collation .....................................................................
10.8.7 Using Collation in INFORMATION_SCHEMA Searches ........................................
10.9 Unicode Support ...........................................................................................................
10.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding) ..............................
10.9.2 The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding) ..............................
10.9.3 The utf8 Character Set (Alias for utf8mb3) ...........................................................
10.9.4 The ucs2 Character Set (UCS-2 Unicode Encoding) ............................................
10.9.5 The utf16 Character Set (UTF-16 Unicode Encoding) ...........................................
10.9.6 The utf16le Character Set (UTF-16LE Unicode Encoding) ....................................
10.9.7 The utf32 Character Set (UTF-32 Unicode Encoding) ...........................................
10.9.8 Converting Between 3-Byte and 4-Byte Unicode Character Sets ...........................
10.10 Supported Character Sets and Collations .....................................................................
10.10.1 Unicode Character Sets ....................................................................................
10.10.2 West European Character Sets .........................................................................
10.10.3 Central European Character Sets ......................................................................
10.10.4 South European and Middle East Character Sets ...............................................
10.10.5 Baltic Character Sets ........................................................................................
10.10.6 Cyrillic Character Sets ......................................................................................
10.10.7 Asian Character Sets ........................................................................................
10.10.8 The Binary Character Set .................................................................................
10.11 Setting the Error Message Language ...........................................................................
10.12 Adding a Character Set ...............................................................................................
10.12.1 Character Definition Arrays ...............................................................................
10.12.2 String Collating Support for Complex Character Sets ..........................................
10.12.3 Multi-Byte Character Support for Complex Character Sets ..................................
10.13 Adding a Collation to a Character Set ..........................................................................
10.13.1 Collation Implementation Types .........................................................................
10.13.2 Choosing a Collation ID ....................................................................................
10.13.3 Adding a Simple Collation to an 8-Bit Character Set ...........................................
10.13.4 Adding a UCA Collation to a Unicode Character Set ...........................................
10.14 Character Set Configuration .........................................................................................
10.15 MySQL Server Locale Support .....................................................................................
x
1224
1226
1226
1227
1228
1229
1230
1231
1233
1233
1235
1236
1236
1243
1245
1245
1247
1247
1248
1248
1248
1250
1251
1253
1255
1256
1257
1258
1258
1258
1259
1259
1259
1262
1263
1268
1269
1270
1271
1271
1272
1275
1276
1277
1279
1280
1280
1280
1281
1284
1285
1286
1294
1295
MySQL 5.6 Reference Manual
11 Data Types ..............................................................................................................................
11.1 Data Type Overview .....................................................................................................
11.1.1 Numeric Type Overview .....................................................................................
11.1.2 Date and Time Type Overview ............................................................................
11.1.3 String Type Overview .........................................................................................
11.2 Numeric Types ..............................................................................................................
11.2.1 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT,
BIGINT .........................................................................................................................
11.2.2 Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC ......................................
11.2.3 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE ..............................
11.2.4 Bit-Value Type - BIT ...........................................................................................
11.2.5 Numeric Type Attributes .....................................................................................
11.2.6 Out-of-Range and Overflow Handling ..................................................................
11.3 Date and Time Types ...................................................................................................
11.3.1 The DATE, DATETIME, and TIMESTAMP Types .................................................
11.3.2 The TIME Type ..................................................................................................
11.3.3 The YEAR Type .................................................................................................
11.3.4 YEAR(2) Limitations and Migrating to YEAR(4) ....................................................
11.3.5 Automatic Initialization and Updating for TIMESTAMP and DATETIME ..................
11.3.6 Fractional Seconds in Time Values .....................................................................
11.3.7 Conversion Between Date and Time Types .........................................................
11.3.8 Two-Digit Years in Dates ....................................................................................
11.4 String Types .................................................................................................................
11.4.1 The CHAR and VARCHAR Types .......................................................................
11.4.2 The BINARY and VARBINARY Types .................................................................
11.4.3 The BLOB and TEXT Types ...............................................................................
11.4.4 The ENUM Type ................................................................................................
11.4.5 The SET Type ...................................................................................................
11.5 Spatial Data Types .......................................................................................................
11.5.1 Spatial Data Types .............................................................................................
11.5.2 The OpenGIS Geometry Model ...........................................................................
11.5.3 Supported Spatial Data Formats .........................................................................
11.5.4 Creating Spatial Columns ...................................................................................
11.5.5 Populating Spatial Columns ................................................................................
11.5.6 Fetching Spatial Data .........................................................................................
11.5.7 Optimizing Spatial Analysis .................................................................................
11.5.8 Creating Spatial Indexes .....................................................................................
11.5.9 Using Spatial Indexes .........................................................................................
11.6 Data Type Default Values .............................................................................................
11.7 Data Type Storage Requirements ..................................................................................
11.8 Choosing the Right Type for a Column ..........................................................................
11.9 Using Data Types from Other Database Engines ............................................................
12 Functions and Operators ..........................................................................................................
12.1 Function and Operator Reference ..................................................................................
12.2 Type Conversion in Expression Evaluation .....................................................................
12.3 Operators .....................................................................................................................
12.3.1 Operator Precedence .........................................................................................
12.3.2 Comparison Functions and Operators .................................................................
12.3.3 Logical Operators ...............................................................................................
12.3.4 Assignment Operators ........................................................................................
12.4 Control Flow Functions ..................................................................................................
12.5 String Functions ............................................................................................................
12.5.1 String Comparison Functions ..............................................................................
12.5.2 Regular Expressions ...........................................................................................
1299
1300
1300
1303
1306
1309
1310
1310
1311
1311
1311
1312
1314
1315
1317
1317
1318
1321
1325
1326
1328
1328
1328
1330
1331
1333
1336
1338
1340
1341
1347
1350
1350
1351
1351
1352
1353
1355
1356
1361
1361
1363
1364
1376
1378
1379
1380
1387
1388
1390
1392
1408
1412
xi
MySQL 5.6 Reference Manual
12.5.3 Character Set and Collation of Function Results ..................................................
12.6 Numeric Functions and Operators ..................................................................................
12.6.1 Arithmetic Operators ...........................................................................................
12.6.2 Mathematical Functions ......................................................................................
12.7 Date and Time Functions ..............................................................................................
12.8 What Calendar Is Used By MySQL? ..............................................................................
12.9 Full-Text Search Functions ............................................................................................
12.9.1 Natural Language Full-Text Searches ..................................................................
12.9.2 Boolean Full-Text Searches ................................................................................
12.9.3 Full-Text Searches with Query Expansion ............................................................
12.9.4 Full-Text Stopwords ............................................................................................
12.9.5 Full-Text Restrictions ..........................................................................................
12.9.6 Fine-Tuning MySQL Full-Text Search ..................................................................
12.9.7 Adding a Collation for Full-Text Indexing .............................................................
12.10 Cast Functions and Operators .....................................................................................
12.11 XML Functions ............................................................................................................
12.12 Bit Functions and Operators ........................................................................................
12.13 Encryption and Compression Functions ........................................................................
12.14 Information Functions ..................................................................................................
12.15 Spatial Analysis Functions ...........................................................................................
12.15.1 Spatial Function Reference ...............................................................................
12.15.2 Argument Handling by Spatial Functions ............................................................
12.15.3 Functions That Create Geometry Values from WKT Values ................................
12.15.4 Functions That Create Geometry Values from WKB Values ................................
12.15.5 MySQL-Specific Functions That Create Geometry Values ...................................
12.15.6 Geometry Format Conversion Functions ............................................................
12.15.7 Geometry Property Functions ............................................................................
12.15.8 Spatial Operator Functions ................................................................................
12.15.9 Functions That Test Spatial Relations Between Geometry Objects ......................
12.16 Functions Used with Global Transaction IDs .................................................................
12.17 MySQL Enterprise Encryption Functions .......................................................................
12.17.1 MySQL Enterprise Encryption Installation ..........................................................
12.17.2 MySQL Enterprise Encryption Usage and Examples ...........................................
12.17.3 MySQL Enterprise Encryption Function Reference .............................................
12.17.4 MySQL Enterprise Encryption Function Descriptions ..........................................
12.18 Aggregate (GROUP BY) Functions ..............................................................................
12.18.1 Aggregate (GROUP BY) Function Descriptions ..................................................
12.18.2 GROUP BY Modifiers .......................................................................................
12.18.3 MySQL Handling of GROUP BY .......................................................................
12.19 Miscellaneous Functions ..............................................................................................
12.20 Precision Math ............................................................................................................
12.20.1 Types of Numeric Values ..................................................................................
12.20.2 DECIMAL Data Type Characteristics .................................................................
12.20.3 Expression Handling .........................................................................................
12.20.4 Rounding Behavior ...........................................................................................
12.20.5 Precision Math Examples ..................................................................................
13 SQL Statement Syntax .............................................................................................................
13.1 Data Definition Statements ............................................................................................
13.1.1 ALTER DATABASE Syntax ................................................................................
13.1.2 ALTER EVENT Syntax .......................................................................................
13.1.3 ALTER FUNCTION Syntax .................................................................................
13.1.4 ALTER LOGFILE GROUP Syntax .......................................................................
13.1.5 ALTER PROCEDURE Syntax .............................................................................
13.1.6 ALTER SERVER Syntax .....................................................................................
xii
1418
1419
1420
1423
1432
1455
1455
1457
1460
1466
1466
1471
1472
1475
1476
1483
1494
1496
1505
1515
1515
1519
1519
1521
1523
1523
1524
1532
1534
1538
1540
1540
1541
1543
1544
1548
1548
1553
1556
1557
1566
1566
1567
1568
1569
1570
1575
1576
1576
1577
1579
1579
1581
1581
MySQL 5.6 Reference Manual
13.2
13.3
13.4
13.5
13.1.7 ALTER TABLE Syntax ........................................................................................
13.1.8 ALTER TABLESPACE Syntax ............................................................................
13.1.9 ALTER VIEW Syntax ..........................................................................................
13.1.10 CREATE DATABASE Syntax ............................................................................
13.1.11 CREATE EVENT Syntax ..................................................................................
13.1.12 CREATE FUNCTION Syntax ............................................................................
13.1.13 CREATE INDEX Syntax ...................................................................................
13.1.14 CREATE LOGFILE GROUP Syntax ..................................................................
13.1.15 CREATE PROCEDURE and CREATE FUNCTION Syntax .................................
13.1.16 CREATE SERVER Syntax ................................................................................
13.1.17 CREATE TABLE Syntax ...................................................................................
13.1.18 CREATE TABLESPACE Syntax ........................................................................
13.1.19 CREATE TRIGGER Syntax ..............................................................................
13.1.20 CREATE VIEW Syntax .....................................................................................
13.1.21 DROP DATABASE Syntax ................................................................................
13.1.22 DROP EVENT Syntax ......................................................................................
13.1.23 DROP FUNCTION Syntax ................................................................................
13.1.24 DROP INDEX Syntax .......................................................................................
13.1.25 DROP LOGFILE GROUP Syntax ......................................................................
13.1.26 DROP PROCEDURE and DROP FUNCTION Syntax .........................................
13.1.27 DROP SERVER Syntax ....................................................................................
13.1.28 DROP TABLE Syntax .......................................................................................
13.1.29 DROP TABLESPACE Syntax ............................................................................
13.1.30 DROP TRIGGER Syntax ..................................................................................
13.1.31 DROP VIEW Syntax .........................................................................................
13.1.32 RENAME TABLE Syntax ..................................................................................
13.1.33 TRUNCATE TABLE Syntax ..............................................................................
Data Manipulation Statements .......................................................................................
13.2.1 CALL Syntax ......................................................................................................
13.2.2 DELETE Syntax .................................................................................................
13.2.3 DO Syntax .........................................................................................................
13.2.4 HANDLER Syntax ..............................................................................................
13.2.5 INSERT Syntax ..................................................................................................
13.2.6 LOAD DATA INFILE Syntax ...............................................................................
13.2.7 LOAD XML Syntax .............................................................................................
13.2.8 REPLACE Syntax ...............................................................................................
13.2.9 SELECT Syntax .................................................................................................
13.2.10 Subquery Syntax ..............................................................................................
13.2.11 UPDATE Syntax ...............................................................................................
Transactional and Locking Statements ...........................................................................
13.3.1 START TRANSACTION, COMMIT, and ROLLBACK Syntax .................................
13.3.2 Statements That Cannot Be Rolled Back .............................................................
13.3.3 Statements That Cause an Implicit Commit .........................................................
13.3.4 SAVEPOINT, ROLLBACK TO SAVEPOINT, and RELEASE SAVEPOINT Syntax ...
13.3.5 LOCK TABLES and UNLOCK TABLES Syntax ....................................................
13.3.6 SET TRANSACTION Syntax ...............................................................................
13.3.7 XA Transactions .................................................................................................
Replication Statements ..................................................................................................
13.4.1 SQL Statements for Controlling Master Servers ...................................................
13.4.2 SQL Statements for Controlling Slave Servers .....................................................
Prepared SQL Statement Syntax ...................................................................................
13.5.1 PREPARE Syntax ..............................................................................................
13.5.2 EXECUTE Syntax ..............................................................................................
13.5.3 DEALLOCATE PREPARE Syntax .......................................................................
1581
1605
1606
1606
1607
1612
1612
1618
1619
1625
1626
1659
1661
1664
1668
1669
1669
1669
1670
1671
1671
1671
1672
1672
1673
1673
1674
1675
1675
1677
1681
1682
1683
1693
1703
1711
1714
1730
1743
1745
1745
1748
1748
1749
1750
1756
1759
1763
1763
1765
1776
1780
1780
1780
xiii
MySQL 5.6 Reference Manual
13.6 Compound-Statement Syntax ........................................................................................
13.6.1 BEGIN ... END Compound-Statement Syntax ......................................................
13.6.2 Statement Label Syntax ......................................................................................
13.6.3 DECLARE Syntax ..............................................................................................
13.6.4 Variables in Stored Programs .............................................................................
13.6.5 Flow Control Statements .....................................................................................
13.6.6 Cursors ..............................................................................................................
13.6.7 Condition Handling .............................................................................................
13.7 Database Administration Statements ..............................................................................
13.7.1 Account Management Statements .......................................................................
13.7.2 Table Maintenance Statements ...........................................................................
13.7.3 Plugin and User-Defined Function Statements .....................................................
13.7.4 SET Syntax ........................................................................................................
13.7.5 SHOW Syntax ....................................................................................................
13.7.6 Other Administrative Statements .........................................................................
13.8 Utility Statements ..........................................................................................................
13.8.1 DESCRIBE Syntax .............................................................................................
13.8.2 EXPLAIN Syntax ................................................................................................
13.8.3 HELP Syntax .....................................................................................................
13.8.4 USE Syntax .......................................................................................................
14 The InnoDB Storage Engine .....................................................................................................
14.1 Introduction to InnoDB ...................................................................................................
14.1.1 Benefits of Using InnoDB Tables ........................................................................
14.1.2 Best Practices for InnoDB Tables ........................................................................
14.1.3 Checking InnoDB Availability ..............................................................................
14.1.4 Testing and Benchmarking with InnoDB ..............................................................
14.1.5 Turning Off InnoDB ............................................................................................
14.2 InnoDB and the ACID Model .........................................................................................
14.3 InnoDB Multi-Versioning ................................................................................................
14.4 InnoDB Architecture ......................................................................................................
14.5 InnoDB In-Memory Structures ........................................................................................
14.5.1 Buffer Pool .........................................................................................................
14.5.2 Change Buffer ....................................................................................................
14.5.3 Adaptive Hash Index ..........................................................................................
14.5.4 Redo Log Buffer .................................................................................................
14.6 InnoDB On-Disk Structures ............................................................................................
14.6.1 Tables ...............................................................................................................
14.6.2 Indexes ..............................................................................................................
14.6.3 Tablespaces .......................................................................................................
14.6.4 InnoDB Data Dictionary ......................................................................................
14.6.5 Doublewrite Buffer ..............................................................................................
14.6.6 Redo Log ...........................................................................................................
14.6.7 Undo Logs .........................................................................................................
14.7 InnoDB Locking and Transaction Model .........................................................................
14.7.1 InnoDB Locking ..................................................................................................
14.7.2 InnoDB Transaction Model ..................................................................................
14.7.3 Locks Set by Different SQL Statements in InnoDB ...............................................
14.7.4 Phantom Rows ...................................................................................................
14.7.5 Deadlocks in InnoDB ..........................................................................................
14.8 InnoDB Configuration ....................................................................................................
14.8.1 InnoDB Startup Configuration ..............................................................................
14.8.2 Configuring InnoDB for Read-Only Operation .......................................................
14.8.3 InnoDB Buffer Pool Configuration ........................................................................
14.8.4 Configuring the Memory Allocator for InnoDB ......................................................
xiv
1781
1781
1781
1782
1783
1784
1789
1791
1817
1817
1837
1847
1850
1855
1906
1917
1917
1917
1918
1921
1923
1925
1926
1927
1928
1929
1929
1930
1931
1933
1933
1934
1938
1941
1942
1942
1942
1965
1971
1982
1982
1983
1984
1984
1985
1989
1997
2000
2001
2004
2004
2010
2011
2018
MySQL 5.6 Reference Manual
14.8.5 Configuring the Number of Background InnoDB I/O Threads .................................
14.8.6 Using Asynchronous I/O on Linux .......................................................................
14.8.7 Configuring the InnoDB Master Thread I/O Rate ..................................................
14.8.8 Configuring Spin Lock Polling .............................................................................
14.8.9 Configuring InnoDB Purge Scheduling .................................................................
14.8.10 Configuring Optimizer Statistics for InnoDB ........................................................
14.8.11 Configuring the Merge Threshold for Index Pages ..............................................
14.9 InnoDB Table Compression ...........................................................................................
14.9.1 Overview of Table Compression .........................................................................
14.9.2 Enabling Compression for a Table ......................................................................
14.9.3 Tuning Compression for InnoDB Tables ..............................................................
14.9.4 Monitoring InnoDB Table Compression at Runtime ..............................................
14.9.5 How Compression Works for InnoDB Tables .......................................................
14.9.6 Compression for OLTP Workloads ......................................................................
14.9.7 SQL Compression Syntax Warnings and Errors ...................................................
14.10 InnoDB File-Format Management .................................................................................
14.10.1 Enabling File Formats .......................................................................................
14.10.2 Verifying File Format Compatibility ....................................................................
14.10.3 Identifying the File Format in Use ......................................................................
14.10.4 Modifying the File Format .................................................................................
14.11 InnoDB Row Storage and Row Formats .......................................................................
14.11.1 Overview of InnoDB Row Storage .....................................................................
14.11.2 Specifying the Row Format for a Table ..............................................................
14.11.3 DYNAMIC and COMPRESSED Row Formats ....................................................
14.11.4 COMPACT and REDUNDANT Row Formats .....................................................
14.12 InnoDB Disk I/O and File Space Management ..............................................................
14.12.1 InnoDB Disk I/O ...............................................................................................
14.12.2 File Space Management ...................................................................................
14.12.3 InnoDB Checkpoints .........................................................................................
14.12.4 Defragmenting a Table .....................................................................................
14.12.5 Reclaiming Disk Space with TRUNCATE TABLE ...............................................
14.13 InnoDB and Online DDL ..............................................................................................
14.13.1 Online DDL Operations .....................................................................................
14.13.2 Online DDL Performance and Concurrency ........................................................
14.13.3 Online DDL Space Requirements ......................................................................
14.13.4 Simplifying DDL Statements with Online DDL ....................................................
14.13.5 Online DDL Failure Conditions ..........................................................................
14.13.6 Online DDL Limitations .....................................................................................
14.14 InnoDB Startup Options and System Variables .............................................................
14.15 InnoDB INFORMATION_SCHEMA Tables ....................................................................
14.15.1 InnoDB INFORMATION_SCHEMA Tables about Compression ...........................
14.15.2 InnoDB INFORMATION_SCHEMA Transaction and Locking Information .............
14.15.3 InnoDB INFORMATION_SCHEMA System Tables .............................................
14.15.4 InnoDB INFORMATION_SCHEMA FULLTEXT Index Tables ..............................
14.15.5 InnoDB INFORMATION_SCHEMA Buffer Pool Tables ........................................
14.15.6 InnoDB INFORMATION_SCHEMA Metrics Table ...............................................
14.16 InnoDB Integration with MySQL Performance Schema ..................................................
14.16.1 Monitoring InnoDB Mutex Waits Using Performance Schema ..............................
14.17 InnoDB Monitors .........................................................................................................
14.17.1 InnoDB Monitor Types ......................................................................................
14.17.2 Enabling InnoDB Monitors ................................................................................
14.17.3 InnoDB Standard Monitor and Lock Monitor Output ............................................
14.17.4 InnoDB Tablespace Monitor Output ...................................................................
14.17.5 InnoDB Table Monitor Output ............................................................................
2018
2019
2020
2020
2021
2021
2033
2035
2036
2036
2037
2041
2042
2045
2046
2048
2049
2049
2052
2053
2054
2054
2054
2054
2055
2056
2056
2057
2058
2058
2059
2059
2060
2069
2072
2073
2074
2074
2075
2156
2156
2158
2163
2169
2172
2177
2186
2187
2191
2191
2192
2195
2200
2203
xv
MySQL 5.6 Reference Manual
14.18 InnoDB Backup and Recovery .....................................................................................
14.18.1 InnoDB Backup ................................................................................................
14.18.2 InnoDB Recovery .............................................................................................
14.19 InnoDB and MySQL Replication ...................................................................................
14.20 InnoDB memcached Plugin ..........................................................................................
14.20.1 Benefits of the InnoDB memcached Plugin ........................................................
14.20.2 InnoDB memcached Architecture ......................................................................
14.20.3 Setting Up the InnoDB memcached Plugin ........................................................
14.20.4 Security Considerations for the InnoDB memcached Plugin ................................
14.20.5 Writing Applications for the InnoDB memcached Plugin ......................................
14.20.6 The InnoDB memcached Plugin and Replication ................................................
14.20.7 InnoDB memcached Plugin Internals .................................................................
14.20.8 Troubleshooting the InnoDB memcached Plugin ................................................
14.21 InnoDB Troubleshooting ..............................................................................................
14.21.1 Troubleshooting InnoDB I/O Problems ...............................................................
14.21.2 Forcing InnoDB Recovery .................................................................................
14.21.3 Troubleshooting InnoDB Data Dictionary Operations ..........................................
14.21.4 InnoDB Error Handling ......................................................................................
15 Alternative Storage Engines .....................................................................................................
15.1 Setting the Storage Engine ............................................................................................
15.2 The MyISAM Storage Engine ........................................................................................
15.2.1 MyISAM Startup Options ....................................................................................
15.2.2 Space Needed for Keys .....................................................................................
15.2.3 MyISAM Table Storage Formats .........................................................................
15.2.4 MyISAM Table Problems ....................................................................................
15.3 The MEMORY Storage Engine ......................................................................................
15.4 The CSV Storage Engine ..............................................................................................
15.4.1 Repairing and Checking CSV Tables ..................................................................
15.4.2 CSV Limitations .................................................................................................
15.5 The ARCHIVE Storage Engine ......................................................................................
15.6 The BLACKHOLE Storage Engine .................................................................................
15.7 The MERGE Storage Engine .........................................................................................
15.7.1 MERGE Table Advantages and Disadvantages ....................................................
15.7.2 MERGE Table Problems .....................................................................................
15.8 The FEDERATED Storage Engine .................................................................................
15.8.1 FEDERATED Storage Engine Overview ..............................................................
15.8.2 How to Create FEDERATED Tables ...................................................................
15.8.3 FEDERATED Storage Engine Notes and Tips .....................................................
15.8.4 FEDERATED Storage Engine Resources ............................................................
15.9 The EXAMPLE Storage Engine .....................................................................................
15.10 Other Storage Engines ................................................................................................
15.11 Overview of MySQL Storage Engine Architecture .........................................................
15.11.1 Pluggable Storage Engine Architecture ..............................................................
15.11.2 The Common Database Server Layer ................................................................
16 High Availability and Scalability ................................................................................................
16.1 Using ZFS Replication ...................................................................................................
16.1.1 Using ZFS for File System Replication ................................................................
16.1.2 Configuring MySQL for ZFS Replication ..............................................................
16.1.3 Handling MySQL Recovery with ZFS ..................................................................
16.2 Using MySQL with memcached .....................................................................................
16.2.1 Installing memcached .........................................................................................
16.2.2 Using memcached ..............................................................................................
16.2.3 Developing a memcached Application .................................................................
16.2.4 Getting memcached Statistics .............................................................................
xvi
2206
2206
2207
2209
2211
2212
2213
2217
2223
2225
2238
2242
2246
2248
2249
2249
2251
2254
2257
2261
2262
2264
2266
2267
2269
2271
2276
2276
2277
2277
2279
2282
2284
2285
2287
2287
2288
2291
2292
2292
2293
2293
2294
2294
2297
2299
2300
2301
2302
2302
2304
2305
2325
2351
MySQL 5.6 Reference Manual
16.2.5 memcached FAQ ...............................................................................................
17 Replication ...............................................................................................................................
17.1 Replication Configuration ...............................................................................................
17.1.1 How to Set Up Replication ..................................................................................
17.1.2 Replication Formats ............................................................................................
17.1.3 Replication with Global Transaction Identifiers .....................................................
17.1.4 Replication and Binary Logging Options and Variables .........................................
17.1.5 Common Replication Administration Tasks ..........................................................
17.2 Replication Implementation ............................................................................................
17.2.1 Replication Implementation Details ......................................................................
17.2.2 Replication Relay and Status Logs ......................................................................
17.2.3 How Servers Evaluate Replication Filtering Rules ................................................
17.3 Replication Solutions .....................................................................................................
17.3.1 Using Replication for Backups ............................................................................
17.3.2 Handling an Unexpected Halt of a Replication Slave ............................................
17.3.3 Using Replication with Different Master and Slave Storage Engines ......................
17.3.4 Using Replication for Scale-Out ..........................................................................
17.3.5 Replicating Different Databases to Different Slaves ..............................................
17.3.6 Improving Replication Performance .....................................................................
17.3.7 Switching Masters During Failover ......................................................................
17.3.8 Setting Up Replication to Use Encrypted Connections ..........................................
17.3.9 Semisynchronous Replication .............................................................................
17.3.10 Delayed Replication ..........................................................................................
17.4 Replication Notes and Tips ............................................................................................
17.4.1 Replication Features and Issues .........................................................................
17.4.2 Replication Compatibility Between MySQL Versions .............................................
17.4.3 Upgrading a Replication Setup ............................................................................
17.4.4 Troubleshooting Replication ................................................................................
17.4.5 How to Report Replication Bugs or Problems ......................................................
18 MySQL NDB Cluster 7.3 and NDB Cluster 7.4 ..........................................................................
18.1 NDB Cluster Overview ..................................................................................................
18.1.1 NDB Cluster Core Concepts ...............................................................................
18.1.2 NDB Cluster Nodes, Node Groups, Replicas, and Partitions .................................
18.1.3 NDB Cluster Hardware, Software, and Networking Requirements ..........................
18.1.4 What is New in MySQL NDB Cluster ...................................................................
18.1.5 MySQL Server Using InnoDB Compared with NDB Cluster ...................................
18.1.6 Known Limitations of NDB Cluster ......................................................................
18.2 NDB Cluster Installation ................................................................................................
18.2.1 The NDB Cluster Auto-Installer ...........................................................................
18.2.2 Installation of NDB Cluster on Linux ....................................................................
18.2.3 Installing NDB Cluster on Windows .....................................................................
18.2.4 Initial Configuration of NDB Cluster .....................................................................
18.2.5 Initial Startup of NDB Cluster ..............................................................................
18.2.6 NDB Cluster Example with Tables and Data ........................................................
18.2.7 Safe Shutdown and Restart of NDB Cluster .........................................................
18.2.8 Upgrading and Downgrading NDB Cluster ...........................................................
18.3 Configuration of NDB Cluster .........................................................................................
18.3.1 Quick Test Setup of NDB Cluster ........................................................................
18.3.2 Overview of NDB Cluster Configuration Parameters, Options, and Variables ..........
18.3.3 NDB Cluster Configuration Files ..........................................................................
18.3.4 Using High-Speed Interconnects with NDB Cluster ...............................................
18.4 NDB Cluster Programs ..................................................................................................
18.4.1 ndbd — The NDB Cluster Data Node Daemon ....................................................
18.4.2 ndbinfo_select_all — Select From ndbinfo Tables .......................................
2360
2365
2366
2367
2378
2385
2395
2475
2478
2479
2480
2487
2492
2493
2496
2499
2500
2501
2502
2503
2505
2507
2512
2513
2513
2540
2541
2542
2543
2545
2549
2550
2553
2556
2557
2561
2564
2575
2577
2589
2596
2605
2607
2608
2611
2612
2615
2615
2618
2636
2817
2818
2818
2826
xvii
MySQL 5.6 Reference Manual
18.4.3 ndbmtd — The NDB Cluster Data Node Daemon (Multi-Threaded) .......................
18.4.4 ndb_mgmd — The NDB Cluster Management Server Daemon ..............................
18.4.5 ndb_mgm — The NDB Cluster Management Client ...............................................
18.4.6 ndb_blob_tool — Check and Repair BLOB and TEXT columns of NDB Cluster
Tables ..........................................................................................................................
18.4.7 ndb_config — Extract NDB Cluster Configuration Information ............................
18.4.8 ndb_cpcd — Automate Testing for NDB Development ........................................
18.4.9 ndb_delete_all — Delete All Rows from an NDB Table ...................................
18.4.10 ndb_desc — Describe NDB Tables ..................................................................
18.4.11 ndb_drop_index — Drop Index from an NDB Table ........................................
18.4.12 ndb_drop_table — Drop an NDB Table .........................................................
18.4.13 ndb_error_reporter — NDB Error-Reporting Utility ......................................
18.4.14 ndb_index_stat — NDB Index Statistics Utility ..............................................
18.4.15 ndb_move_data — NDB Data Copy Utility .......................................................
18.4.16 ndb_print_backup_file — Print NDB Backup File Contents .........................
18.4.17 ndb_print_file — Print NDB Disk Data File Contents ...................................
18.4.18 ndb_print_frag_file — Print NDB Fragment List File Contents ....................
18.4.19 ndb_print_schema_file — Print NDB Schema File Contents ........................
18.4.20 ndb_print_sys_file — Print NDB System File Contents ...............................
18.4.21 ndb_redo_log_reader — Check and Print Content of Cluster Redo Log ..........
18.4.22 ndb_restore — Restore an NDB Cluster Backup ............................................
18.4.23 ndb_select_all — Print Rows from an NDB Table ........................................
18.4.24 ndb_select_count — Print Row Counts for NDB Tables ................................
18.4.25 ndb_setup.py — Start browser-based Auto-Installer for NDB Cluster ................
18.4.26 ndb_show_tables — Display List of NDB Tables ............................................
18.4.27 ndb_size.pl — NDBCLUSTER Size Requirement Estimator ...........................
18.4.28 ndb_waiter — Wait for NDB Cluster to Reach a Given Status ..........................
18.4.29 Options Common to NDB Cluster Programs — Options Common to NDB Cluster
Programs ......................................................................................................................
18.5 Management of NDB Cluster .........................................................................................
18.5.1 Summary of NDB Cluster Start Phases ...............................................................
18.5.2 Commands in the NDB Cluster Management Client .............................................
18.5.3 Online Backup of NDB Cluster ............................................................................
18.5.4 MySQL Server Usage for NDB Cluster ................................................................
18.5.5 Performing a Rolling Restart of an NDB Cluster ...................................................
18.5.6 Event Reports Generated in NDB Cluster ............................................................
18.5.7 NDB Cluster Log Messages ................................................................................
18.5.8 NDB Cluster Single User Mode ...........................................................................
18.5.9 Quick Reference: NDB Cluster SQL Statements ..................................................
18.5.10 ndbinfo: The NDB Cluster Information Database ................................................
18.5.11 NDB Cluster Security Issues .............................................................................
18.5.12 NDB Cluster Disk Data Tables ..........................................................................
18.5.13 Adding NDB Cluster Data Nodes Online ............................................................
18.5.14 Distributed MySQL Privileges for NDB Cluster ...................................................
18.5.15 NDB API Statistics Counters and Variables ........................................................
18.6 NDB Cluster Replication ................................................................................................
18.6.1 NDB Cluster Replication: Abbreviations and Symbols ...........................................
18.6.2 General Requirements for NDB Cluster Replication ..............................................
18.6.3 Known Issues in NDB Cluster Replication ............................................................
18.6.4 NDB Cluster Replication Schema and Tables ......................................................
18.6.5 Preparing the NDB Cluster for Replication ...........................................................
18.6.6 Starting NDB Cluster Replication (Single Replication Channel) ..............................
18.6.7 Using Two Replication Channels for NDB Cluster Replication ...............................
18.6.8 Implementing Failover with NDB Cluster Replication ............................................
xviii
2828
2829
2837
2839
2842
2851
2851
2852
2857
2858
2858
2860
2866
2869
2869
2869
2870
2871
2871
2875
2896
2899
2900
2904
2905
2908
2911
2916
2917
2919
2923
2928
2929
2931
2942
2957
2958
2961
2997
3004
3012
3023
3026
3038
3039
3039
3040
3047
3051
3052
3054
3055
MySQL 5.6 Reference Manual
18.6.9 NDB Cluster Backups With NDB Cluster Replication ............................................
18.6.10 NDB Cluster Replication: Multi-Master and Circular Replication ...........................
18.6.11 NDB Cluster Replication Conflict Resolution ......................................................
18.7 NDB Cluster Release Notes ..........................................................................................
19 Partitioning ..............................................................................................................................
19.1 Overview of Partitioning in MySQL .................................................................................
19.2 Partitioning Types .........................................................................................................
19.2.1 RANGE Partitioning ............................................................................................
19.2.2 LIST Partitioning .................................................................................................
19.2.3 COLUMNS Partitioning .......................................................................................
19.2.4 HASH Partitioning ..............................................................................................
19.2.5 KEY Partitioning .................................................................................................
19.2.6 Subpartitioning ...................................................................................................
19.2.7 How MySQL Partitioning Handles NULL ..............................................................
19.3 Partition Management ...................................................................................................
19.3.1 Management of RANGE and LIST Partitions ........................................................
19.3.2 Management of HASH and KEY Partitions ..........................................................
19.3.3 Exchanging Partitions and Subpartitions with Tables ............................................
19.3.4 Maintenance of Partitions ...................................................................................
19.3.5 Obtaining Information About Partitions .................................................................
19.4 Partition Pruning ...........................................................................................................
19.5 Partition Selection .........................................................................................................
19.6 Restrictions and Limitations on Partitioning .....................................................................
19.6.1 Partitioning Keys, Primary Keys, and Unique Keys ...............................................
19.6.2 Partitioning Limitations Relating to Storage Engines .............................................
19.6.3 Partitioning Limitations Relating to Functions .......................................................
19.6.4 Partitioning and Locking .....................................................................................
20 Stored Programs and Views .....................................................................................................
20.1 Defining Stored Programs .............................................................................................
20.2 Using Stored Routines (Procedures and Functions) ........................................................
20.2.1 Stored Routine Syntax ........................................................................................
20.2.2 Stored Routines and MySQL Privileges ...............................................................
20.2.3 Stored Routine Metadata ....................................................................................
20.2.4 Stored Procedures, Functions, Triggers, and LAST_INSERT_ID() .........................
20.3 Using Triggers ..............................................................................................................
20.3.1 Trigger Syntax and Examples .............................................................................
20.3.2 Trigger Metadata ................................................................................................
20.4 Using the Event Scheduler ............................................................................................
20.4.1 Event Scheduler Overview ..................................................................................
20.4.2 Event Scheduler Configuration ............................................................................
20.4.3 Event Syntax ......................................................................................................
20.4.4 Event Metadata ..................................................................................................
20.4.5 Event Scheduler Status ......................................................................................
20.4.6 The Event Scheduler and MySQL Privileges ........................................................
20.5 Using Views ..................................................................................................................
20.5.1 View Syntax .......................................................................................................
20.5.2 View Processing Algorithms ................................................................................
20.5.3 Updatable and Insertable Views ..........................................................................
20.5.4 The View WITH CHECK OPTION Clause ............................................................
20.5.5 View Metadata ...................................................................................................
20.6 Access Control for Stored Programs and Views ..............................................................
20.7 Binary Logging of Stored Programs ...............................................................................
21 INFORMATION_SCHEMA Tables ............................................................................................
21.1 Introduction ...................................................................................................................
3057
3063
3067
3082
3083
3085
3088
3090
3094
3096
3104
3108
3109
3113
3117
3118
3125
3126
3131
3133
3135
3138
3144
3151
3155
3156
3157
3159
3160
3161
3162
3162
3163
3163
3163
3164
3168
3168
3169
3170
3172
3172
3173
3174
3176
3177
3177
3179
3180
3181
3181
3183
3191
3192
xix
MySQL 5.6 Reference Manual
21.2 The INFORMATION_SCHEMA CHARACTER_SETS Table ............................................ 3195
21.3 The INFORMATION_SCHEMA COLLATIONS Table ....................................................... 3196
21.4 The INFORMATION_SCHEMA COLLATION_CHARACTER_SET_APPLICABILITY Table 3196
21.5 The INFORMATION_SCHEMA COLUMNS Table ........................................................... 3197
21.6 The INFORMATION_SCHEMA COLUMN_PRIVILEGES Table ........................................ 3199
21.7 The INFORMATION_SCHEMA ENGINES Table ............................................................. 3200
21.8 The INFORMATION_SCHEMA EVENTS Table .............................................................. 3201
21.9 The INFORMATION_SCHEMA GLOBAL_STATUS and SESSION_STATUS Tables ......... 3205
21.10 The INFORMATION_SCHEMA GLOBAL_VARIABLES and SESSION_VARIABLES
Tables .................................................................................................................................. 3205
21.11 The INFORMATION_SCHEMA KEY_COLUMN_USAGE Table ...................................... 3205
21.12 The INFORMATION_SCHEMA OPTIMIZER_TRACE Table ........................................... 3207
21.13 The INFORMATION_SCHEMA PARAMETERS Table ................................................... 3207
21.14 The INFORMATION_SCHEMA PARTITIONS Table ...................................................... 3209
21.15 The INFORMATION_SCHEMA PLUGINS Table ........................................................... 3212
21.16 The INFORMATION_SCHEMA PROCESSLIST Table ................................................... 3213
21.17 The INFORMATION_SCHEMA PROFILING Table ........................................................ 3215
21.18 The INFORMATION_SCHEMA REFERENTIAL_CONSTRAINTS Table ......................... 3216
21.19 The INFORMATION_SCHEMA ROUTINES Table ......................................................... 3217
21.20 The INFORMATION_SCHEMA SCHEMATA Table ....................................................... 3220
21.21 The INFORMATION_SCHEMA SCHEMA_PRIVILEGES Table ...................................... 3220
21.22 The INFORMATION_SCHEMA STATISTICS Table ....................................................... 3221
21.23 The INFORMATION_SCHEMA TABLES Table ............................................................. 3223
21.24 The INFORMATION_SCHEMA TABLESPACES Table .................................................. 3226
21.25 The INFORMATION_SCHEMA TABLE_CONSTRAINTS Table ...................................... 3227
21.26 The INFORMATION_SCHEMA TABLE_PRIVILEGES Table .......................................... 3228
21.27 The INFORMATION_SCHEMA TRIGGERS Table ........................................................ 3228
21.28 The INFORMATION_SCHEMA USER_PRIVILEGES Table ........................................... 3230
21.29 The INFORMATION_SCHEMA VIEWS Table ............................................................... 3231
21.30 INFORMATION_SCHEMA InnoDB Tables .................................................................... 3233
21.30.1 The INFORMATION_SCHEMA INNODB_BUFFER_PAGE Table ........................ 3233
21.30.2 The INFORMATION_SCHEMA INNODB_BUFFER_PAGE_LRU Table ................ 3236
21.30.3 The INFORMATION_SCHEMA INNODB_BUFFER_POOL_STATS Table ............ 3239
21.30.4 The INFORMATION_SCHEMA INNODB_CMP and INNODB_CMP_RESET
Tables .......................................................................................................................... 3242
21.30.5 The INFORMATION_SCHEMA INNODB_CMPMEM and
INNODB_CMPMEM_RESET Tables .............................................................................. 3244
21.30.6 The INFORMATION_SCHEMA INNODB_CMP_PER_INDEX and
INNODB_CMP_PER_INDEX_RESET Tables ................................................................. 3245
21.30.7 The INFORMATION_SCHEMA INNODB_FT_BEING_DELETED Table ............... 3247
21.30.8 The INFORMATION_SCHEMA INNODB_FT_CONFIG Table .............................. 3247
21.30.9 The INFORMATION_SCHEMA INNODB_FT_DEFAULT_STOPWORD Table ...... 3248
21.30.10 The INFORMATION_SCHEMA INNODB_FT_DELETED Table ......................... 3250
21.30.11 The INFORMATION_SCHEMA INNODB_FT_INDEX_CACHE Table ................. 3250
21.30.12 The INFORMATION_SCHEMA INNODB_FT_INDEX_TABLE Table .................. 3252
21.30.13 The INFORMATION_SCHEMA INNODB_LOCKS Table ................................... 3254
21.30.14 The INFORMATION_SCHEMA INNODB_LOCK_WAITS Table ......................... 3255
21.30.15 The INFORMATION_SCHEMA INNODB_METRICS Table ................................ 3256
21.30.16 The INFORMATION_SCHEMA INNODB_SYS_COLUMNS Table ...................... 3258
21.30.17 The INFORMATION_SCHEMA INNODB_SYS_DATAFILES Table .................... 3259
21.30.18 The INFORMATION_SCHEMA INNODB_SYS_FIELDS Table ........................... 3260
21.30.19 The INFORMATION_SCHEMA INNODB_SYS_FOREIGN Table ....................... 3261
21.30.20 The INFORMATION_SCHEMA INNODB_SYS_FOREIGN_COLS Table ............ 3261
21.30.21 The INFORMATION_SCHEMA INNODB_SYS_INDEXES Table ........................ 3262
xx
MySQL 5.6 Reference Manual
21.30.22 The INFORMATION_SCHEMA INNODB_SYS_TABLES Table .........................
21.30.23 The INFORMATION_SCHEMA INNODB_SYS_TABLESPACES Table ..............
21.30.24 The INFORMATION_SCHEMA INNODB_SYS_TABLESTATS View ..................
21.30.25 The INFORMATION_SCHEMA INNODB_TRX Table ........................................
21.31 INFORMATION_SCHEMA NDB Cluster Tables ............................................................
21.31.1 The INFORMATION_SCHEMA FILES Table ......................................................
21.31.2 The INFORMATION_SCHEMA ndb_transid_mysql_connection_map Table .........
21.32 INFORMATION_SCHEMA Thread Pool Tables .............................................................
21.32.1 The INFORMATION_SCHEMA TP_THREAD_GROUP_STATE Table .................
21.32.2 The INFORMATION_SCHEMA TP_THREAD_GROUP_STATS Table .................
21.32.3 The INFORMATION_SCHEMA TP_THREAD_STATE Table ...............................
21.33 INFORMATION_SCHEMA Connection-Control Tables ..................................................
21.33.1 The INFORMATION_SCHEMA
CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS Table .....................................
21.34 Extensions to SHOW Statements .................................................................................
22 MySQL Performance Schema ..................................................................................................
22.1 Performance Schema Quick Start ..................................................................................
22.2 Performance Schema Build Configuration ......................................................................
22.3 Performance Schema Startup Configuration ...................................................................
22.4 Performance Schema Runtime Configuration .................................................................
22.4.1 Performance Schema Event Timing ....................................................................
22.4.2 Performance Schema Event Filtering ...................................................................
22.4.3 Event Pre-Filtering ..............................................................................................
22.4.4 Pre-Filtering by Instrument ..................................................................................
22.4.5 Pre-Filtering by Object ........................................................................................
22.4.6 Pre-Filtering by Thread .......................................................................................
22.4.7 Pre-Filtering by Consumer ..................................................................................
22.4.8 Example Consumer Configurations .....................................................................
22.4.9 Naming Instruments or Consumers for Filtering Operations ...................................
22.4.10 Determining What Is Instrumented .....................................................................
22.5 Performance Schema Queries .......................................................................................
22.6 Performance Schema Instrument Naming Conventions ...................................................
22.7 Performance Schema Status Monitoring .........................................................................
22.8 Performance Schema Atom and Molecule Events ...........................................................
22.9 Performance Schema Tables for Current and Historical Events .......................................
22.10 Performance Schema Statement Digests ......................................................................
22.11 Performance Schema General Table Characteristics .....................................................
22.12 Performance Schema Table Descriptions .....................................................................
22.12.1 Performance Schema Table Index .....................................................................
22.12.2 Performance Schema Setup Tables ..................................................................
22.12.3 Performance Schema Instance Tables ..............................................................
22.12.4 Performance Schema Wait Event Tables ...........................................................
22.12.5 Performance Schema Stage Event Tables .........................................................
22.12.6 Performance Schema Statement Event Tables ..................................................
22.12.7 Performance Schema Connection Tables ..........................................................
22.12.8 Performance Schema Connection Attribute Tables .............................................
22.12.9 Performance Schema Summary Tables .............................................................
22.12.10 Performance Schema Miscellaneous Tables ....................................................
22.13 Performance Schema Option and Variable Reference ...................................................
22.14 Performance Schema Command Options .....................................................................
22.15 Performance Schema System Variables .......................................................................
22.16 Performance Schema Status Variables ........................................................................
22.17 Performance Schema and Plugins ...............................................................................
22.18 Using the Performance Schema to Diagnose Problems .................................................
3263
3265
3266
3267
3270
3270
3276
3277
3278
3279
3281
3282
3282
3283
3287
3289
3295
3296
3299
3300
3303
3304
3305
3307
3308
3310
3312
3317
3318
3318
3319
3321
3325
3325
3327
3330
3331
3332
3333
3338
3343
3348
3353
3361
3364
3367
3380
3388
3390
3391
3405
3407
3407
xxi
MySQL 5.6 Reference Manual
22.18.1 Query Profiling Using Performance Schema ......................................................
23 Connectors and APIs ...............................................................................................................
23.1 MySQL Connector/C .....................................................................................................
23.2 MySQL Connector/C++ .................................................................................................
23.3 MySQL Connector/J ......................................................................................................
23.4 MySQL Connector/NET .................................................................................................
23.5 MySQL Connector/ODBC ..............................................................................................
23.6 MySQL Connector/Python .............................................................................................
23.7 libmysqld, the Embedded MySQL Server Library ............................................................
23.7.1 Compiling Programs with libmysqld .....................................................................
23.7.2 Restrictions When Using the Embedded MySQL Server .......................................
23.7.3 Options with the Embedded Server .....................................................................
23.7.4 Embedded Server Examples ...............................................................................
23.8 MySQL C API ...............................................................................................................
23.8.1 MySQL C API Implementations ...........................................................................
23.8.2 Simultaneous MySQL Server and Connector/C Installations ..................................
23.8.3 Example C API Client Programs .........................................................................
23.8.4 Building and Running C API Client Programs ......................................................
23.8.5 C API Data Structures ........................................................................................
23.8.6 C API Function Overview ...................................................................................
23.8.7 C API Function Descriptions ...............................................................................
23.8.8 C API Prepared Statements ................................................................................
23.8.9 C API Prepared Statement Data Structures .........................................................
23.8.10 C API Prepared Statement Function Overview ...................................................
23.8.11 C API Prepared Statement Function Descriptions ...............................................
23.8.12 C API Threaded Function Descriptions ..............................................................
23.8.13 C API Embedded Server Function Descriptions ..................................................
23.8.14 C API Client Plugin Functions ...........................................................................
23.8.15 C API Encrypted Connection Support ................................................................
23.8.16 C API Multiple Statement Execution Support ......................................................
23.8.17 C API Prepared Statement Handling of Date and Time Values ............................
23.8.18 C API Prepared CALL Statement Support ..........................................................
23.8.19 C API Prepared Statement Problems ................................................................
23.8.20 C API Automatic Reconnection Control ..............................................................
23.8.21 C API Common Issues .....................................................................................
23.9 MySQL PHP API ..........................................................................................................
23.10 MySQL Perl API ..........................................................................................................
23.11 MySQL Python API .....................................................................................................
23.12 MySQL Ruby APIs ......................................................................................................
23.12.1 The MySQL/Ruby API ......................................................................................
23.12.2 The Ruby/MySQL API ......................................................................................
23.13 MySQL Tcl API ...........................................................................................................
23.14 MySQL Eiffel Wrapper .................................................................................................
24 Extending MySQL ....................................................................................................................
24.1 MySQL Internals ...........................................................................................................
24.1.1 MySQL Threads .................................................................................................
24.1.2 The MySQL Test Suite .......................................................................................
24.2 The MySQL Plugin API .................................................................................................
24.2.1 Types of Plugins ................................................................................................
24.2.2 Plugin API Characteristics ..................................................................................
24.2.3 Plugin API Components ......................................................................................
24.2.4 Writing Plugins ...................................................................................................
24.3 MySQL Services for Plugins ..........................................................................................
24.4 Adding New Functions to MySQL ..................................................................................
xxii
3409
3411
3414
3414
3414
3415
3415
3415
3415
3416
3416
3417
3417
3421
3421
3422
3423
3424
3428
3433
3438
3495
3495
3502
3504
3528
3530
3531
3534
3536
3538
3540
3544
3544
3545
3547
3547
3548
3548
3548
3548
3548
3549
3551
3551
3551
3552
3553
3553
3556
3557
3558
3603
3605
MySQL 5.6 Reference Manual
24.4.1 Features of the User-Defined Function Interface ..................................................
24.4.2 Adding a New User-Defined Function ..................................................................
24.4.3 Adding a New Native Function ............................................................................
24.5 Debugging and Porting MySQL .....................................................................................
24.5.1 Debugging a MySQL Server ...............................................................................
24.5.2 Debugging a MySQL Client ................................................................................
24.5.3 The DBUG Package ...........................................................................................
25 MySQL Enterprise Edition ........................................................................................................
25.1 MySQL Enterprise Monitor Overview ..............................................................................
25.2 MySQL Enterprise Backup Overview ..............................................................................
25.3 MySQL Enterprise Security Overview .............................................................................
25.4 MySQL Enterprise Encryption Overview .........................................................................
25.5 MySQL Enterprise Audit Overview .................................................................................
25.6 MySQL Enterprise Firewall Overview .............................................................................
25.7 MySQL Enterprise Thread Pool Overview ......................................................................
25.8 MySQL Enterprise Data Masking and De-Identification Overview .....................................
26 MySQL Workbench ..................................................................................................................
A MySQL 5.6 Frequently Asked Questions ....................................................................................
A.1 MySQL 5.6 FAQ: General ...............................................................................................
A.2 MySQL 5.6 FAQ: Storage Engines ..................................................................................
A.3 MySQL 5.6 FAQ: Server SQL Mode ................................................................................
A.4 MySQL 5.6 FAQ: Stored Procedures and Functions .........................................................
A.5 MySQL 5.6 FAQ: Triggers ..............................................................................................
A.6 MySQL 5.6 FAQ: Views ..................................................................................................
A.7 MySQL 5.6 FAQ: INFORMATION_SCHEMA ....................................................................
A.8 MySQL 5.6 FAQ: Migration .............................................................................................
A.9 MySQL 5.6 FAQ: Security ...............................................................................................
A.10 MySQL 5.6 FAQ: NDB Cluster ......................................................................................
A.11 MySQL 5.6 FAQ: MySQL Chinese, Japanese, and Korean Character Sets ......................
A.12 MySQL 5.6 FAQ: Connectors & APIs ............................................................................
A.13 MySQL 5.6 FAQ: Replication ........................................................................................
A.14 MySQL 5.6 FAQ: MySQL Enterprise Thread Pool ..........................................................
A.15 MySQL 5.6 FAQ: InnoDB Change Buffer .......................................................................
A.16 MySQL 5.6 FAQ: Virtualization Support .........................................................................
B Errors, Error Codes, and Common Problems ..............................................................................
B.1 Error Information Interfaces .............................................................................................
B.2 Error Message Components ............................................................................................
B.3 Server Error Message Reference ....................................................................................
B.4 Client Error Message Reference .....................................................................................
B.5 Problems and Common Errors ........................................................................................
B.5.1 How to Determine What Is Causing a Problem ......................................................
B.5.2 Common Errors When Using MySQL Programs ....................................................
B.5.3 Administration-Related Issues ...............................................................................
B.5.4 Query-Related Issues ...........................................................................................
B.5.5 Optimizer-Related Issues .....................................................................................
B.5.6 Table Definition-Related Issues ............................................................................
B.5.7 Known Issues in MySQL ......................................................................................
C Restrictions and Limits ..............................................................................................................
C.1 Restrictions on Stored Programs .....................................................................................
C.2 Restrictions on Condition Handling ..................................................................................
C.3 Restrictions on Server-Side Cursors ................................................................................
C.4 Restrictions on Subqueries .............................................................................................
C.5 Restrictions on Views .....................................................................................................
C.6 Restrictions on XA Transactions .....................................................................................
3606
3606
3616
3618
3618
3625
3626
3631
3631
3632
3633
3633
3633
3634
3634
3634
3635
3637
3637
3638
3639
3640
3644
3646
3647
3647
3648
3649
3662
3675
3675
3679
3681
3682
3685
3685
3686
3687
3762
3766
3766
3768
3781
3789
3797
3797
3798
3803
3803
3807
3807
3808
3809
3811
xxiii
MySQL 5.6 Reference Manual
C.7 Restrictions on Character Sets ........................................................................................
C.8 Restrictions on Performance Schema ..............................................................................
C.9 Restrictions on Pluggable Authentication .........................................................................
C.10 Limits in MySQL ...........................................................................................................
C.10.1 Limits on Joins ..................................................................................................
C.10.2 Limits on Number of Databases and Tables ........................................................
C.10.3 Limits on Table Size ..........................................................................................
C.10.4 Limits on Table Column Count and Row Size ......................................................
C.10.5 Limits Imposed by .frm File Structure ..................................................................
C.10.6 Windows Platform Limitations .............................................................................
D Indexes .....................................................................................................................................
MySQL Glossary ...........................................................................................................................
xxiv
3811
3811
3812
3813
3814
3814
3814
3815
3818
3819
3821
4449
Preface and Legal Notices
This is the Reference Manual for the MySQL Database System, version 5.6, through release 5.6.43.
Differences between minor versions of MySQL 5.6 are noted in the present text with reference to release
numbers (5.6.x). For license information, see the Legal Notices.
This manual is not intended for use with older versions of the MySQL software due to the many functional
and other differences between MySQL 5.6 and previous versions. If you are using an earlier release of
the MySQL software, please refer to the appropriate manual. For example, MySQL 5.5 Reference Manual
covers the 5.5 series of MySQL software releases.
If you are using MySQL 5.7, please refer to the MySQL 5.7 Reference Manual.
Licensing information—MySQL 5.6.
This product may include third-party software, used under
license. If you are using a Commercial release of MySQL 5.6, see the MySQL 5.6 Commercial Release
License Information User Manual for licensing information, including licensing information relating to thirdparty software that may be included in this Commercial release. If you are using a Community release
of MySQL 5.6, see the MySQL 5.6 Community Release License Information User Manual for licensing
information, including licensing information relating to third-party software that may be included in this
Community release.
Licensing information—MySQL NDB Cluster 7.3.
This product may include third-party software, used
under license. If you are using a Commercial release of NDB Cluster 7.3, see the MySQL NDB Cluster
7.3 Commercial Release License Information User Manual for licensing information relating to third-party
software that may be included in this Commercial release. If you are using a Community release of NDB
Cluster 7.3, see the MySQL NDB Cluster 7.3 Community Release License Information User Manual for
licensing information relating to third-party software that may be included in this Community release.
Licensing information—MySQL NDB Cluster 7.4.
This product may include third-party software, used
under license. If you are using a Commercial release of NDB Cluster 7.4, see the MySQL NDB Cluster
7.4 Commercial Release License Information User Manual for licensing information relating to third-party
software that may be included in this Commercial release. If you are using a Community release of NDB
Cluster 7.4, see the MySQL NDB Cluster 7.4 Community Release License Information User Manual for
licensing information relating to third-party software that may be included in this Community release.
Legal Notices
Copyright © 1997, 2018, Oracle and/or its affiliates. All rights reserved.
This software and related documentation are provided under a license agreement containing restrictions
on use and disclosure and are protected by intellectual property laws. Except as expressly permitted
in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast,
modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any
means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for
interoperability, is prohibited.
The information contained herein is subject to change without notice and is not warranted to be error-free.
If you find any errors, please report them to us in writing.
If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it
on behalf of the U.S. Government, then the following notice is applicable:
U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software,
any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users
are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-
xxv
Documentation Accessibility
specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the
programs, including any operating system, integrated software, any programs installed on the hardware,
and/or documentation, shall be subject to license terms and license restrictions applicable to the programs.
No other rights are granted to the U.S. Government.
This software or hardware is developed for general use in a variety of information management
applications. It is not developed or intended for use in any inherently dangerous applications, including
applications that may create a risk of personal injury. If you use this software or hardware in dangerous
applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other
measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages
caused by use of this software or hardware in dangerous applications.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks
of their respective owners.
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks
are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD,
Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced
Micro Devices. UNIX is a registered trademark of The Open Group.
This software or hardware and documentation may provide access to or information about content,
products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and
expressly disclaim all warranties of any kind with respect to third-party content, products, and services
unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its
affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of
third-party content, products, or services, except as set forth in an applicable agreement between you and
Oracle.
This documentation is NOT distributed under a GPL license. Use of this documentation is subject to the
following terms:
You may create a printed copy of this documentation solely for your own personal use. Conversion to other
formats is allowed as long as the actual content is not altered or edited in any way. You shall not publish
or distribute this documentation in any form or on any media, except if you distribute the documentation in
a manner similar to how Oracle disseminates it (that is, electronically for download on a Web site with the
software) or on a CD-ROM or similar medium, provided however that the documentation is disseminated
together with the software on the same medium. Any other use, such as any dissemination of printed
copies or use of this documentation, in whole or in part, in another publication, requires the prior written
consent from an authorized representative of Oracle. Oracle and/or its affiliates reserve any and all rights
to this documentation not expressly granted above.
Documentation Accessibility
For information about Oracle's commitment to accessibility, visit the Oracle Accessibility Program website
at
http://www.oracle.com/pls/topic/lookup?ctx=acc&id=docacc.
Access to Oracle Support
Oracle customers that have purchased support have access to electronic support through My Oracle
Support. For information, visit
http://www.oracle.com/pls/topic/lookup?ctx=acc&id=info or visit http://www.oracle.com/pls/topic/lookup?
ctx=acc&id=trs if you are hearing impaired.
xxvi
Chapter 1 General Information
Table of Contents
1.1 About This Manual ....................................................................................................................... 2
1.2 Typographical and Syntax Conventions ......................................................................................... 3
1.3 Overview of the MySQL Database Management System ................................................................ 4
1.3.1 What is MySQL? ............................................................................................................... 4
1.3.2 The Main Features of MySQL ............................................................................................ 6
1.3.3 History of MySQL .............................................................................................................. 9
1.4 What Is New in MySQL 5.6 .......................................................................................................... 9
1.5 MySQL Information Sources ....................................................................................................... 22
1.5.1 MySQL Websites ............................................................................................................. 22
1.5.2 MySQL Mailing Lists ........................................................................................................ 22
1.5.3 MySQL Community Support at the MySQL Forums ........................................................... 24
1.5.4 MySQL Community Support on Internet Relay Chat (IRC) .................................................. 25
1.5.5 MySQL Enterprise ............................................................................................................ 25
1.6 How to Report Bugs or Problems ................................................................................................ 25
1.7 MySQL Standards Compliance .................................................................................................... 30
1.7.1 MySQL Extensions to Standard SQL ................................................................................ 31
1.7.2 MySQL Differences from Standard SQL ............................................................................ 34
1.7.3 How MySQL Deals with Constraints ................................................................................. 36
1.8 Credits ....................................................................................................................................... 39
1.8.1 Contributors to MySQL ..................................................................................................... 39
1.8.2 Documenters and translators ............................................................................................ 44
1.8.3 Packages that support MySQL ......................................................................................... 45
1.8.4 Tools that were used to create MySQL ............................................................................. 46
1.8.5 Supporters of MySQL ...................................................................................................... 46
The MySQL™ software delivers a very fast, multithreaded, multi-user, and robust SQL (Structured
Query Language) database server. MySQL Server is intended for mission-critical, heavy-load production
systems as well as for embedding into mass-deployed software. Oracle is a registered trademark of Oracle
Corporation and/or its affiliates. MySQL is a trademark of Oracle Corporation and/or its affiliates, and shall
not be used by Customer without Oracle's express written authorization. Other names may be trademarks
of their respective owners.
The MySQL software is Dual Licensed. Users can choose to use the MySQL software as an Open Source
product under the terms of the GNU General Public License (http://www.fsf.org/licenses/) or can purchase
a standard commercial license from Oracle. See http://www.mysql.com/company/legal/licensing/ for more
information on our licensing policies.
The following list describes some sections of particular interest in this manual:
• For a discussion of MySQL Database Server capabilities, see Section 1.3.2, “The Main Features of
MySQL”.
• For an overview of new MySQL features, see Section 1.4, “What Is New in MySQL 5.6”. For information
about the changes in each version, see the Release Notes.
• For installation instructions, see Chapter 2, Installing and Upgrading MySQL. For information about
upgrading MySQL, see Section 2.11.1, “Upgrading MySQL”.
1
About This Manual
• For a tutorial introduction to the MySQL Database Server, see Chapter 3, Tutorial.
• For information about configuring and administering MySQL Server, see Chapter 5, MySQL Server
Administration.
• For information about security in MySQL, see Chapter 6, Security.
• For information about setting up replication servers, see Chapter 17, Replication.
• For information about MySQL Enterprise, the commercial MySQL release with advanced features and
management tools, see Chapter 25, MySQL Enterprise Edition.
• For answers to a number of questions that are often asked concerning the MySQL Database Server and
its capabilities, see Appendix A, MySQL 5.6 Frequently Asked Questions.
• For a history of new features and bug fixes, see the Release Notes.
Important
To report problems or bugs, please use the instructions at Section 1.6, “How
to Report Bugs or Problems”. If you find a sensitive security bug in MySQL
Server, please let us know immediately by sending an email message to
. Exception: Support customers should report all
problems, including security bugs, to Oracle Support.
1.1 About This Manual
This is the Reference Manual for the MySQL Database System, version 5.6, through release 5.6.43.
Differences between minor versions of MySQL 5.6 are noted in the present text with reference to release
numbers (5.6.x). For license information, see the Legal Notices.
This manual is not intended for use with older versions of the MySQL software due to the many functional
and other differences between MySQL 5.6 and previous versions. If you are using an earlier release of
the MySQL software, please refer to the appropriate manual. For example, MySQL 5.5 Reference Manual
covers the 5.5 series of MySQL software releases.
Because this manual serves as a reference, it does not provide general instruction on SQL or relational
database concepts. It also does not teach you how to use your operating system or command-line
interpreter.
The MySQL Database Software is under constant development, and the Reference Manual is updated
frequently as well. The most recent version of the manual is available online in searchable form at https://
dev.mysql.com/doc/. Other formats also are available there, including HTML, PDF, and EPUB versions.
The Reference Manual source files are written in DocBook XML format. The HTML version and other
formats are produced automatically, primarily using the DocBook XSL stylesheets. For information about
DocBook, see http://docbook.org/
If you have questions about using MySQL, you can ask them using our mailing lists or forums. See
Section 1.5.2, “MySQL Mailing Lists”, and Section 1.5.3, “MySQL Community Support at the MySQL
Forums”. If you have suggestions concerning additions or corrections to the manual itself, please send
them to the http://www.mysql.com/company/contact/.
This manual was originally written by David Axmark and Michael “Monty” Widenius. It is maintained by the
MySQL Documentation Team, consisting of Chris Cole, Paul DuBois, Margaret Fisher, Edward Gilmore,
Stefan Hinz, David Moss, Philip Olson, Daniel Price, Daniel So, and Jon Stephens.
2
Typographical and Syntax Conventions
1.2 Typographical and Syntax Conventions
This manual uses certain typographical conventions:
• Text in this style is used for SQL statements; database, table, and column names; program
listings and source code; and environment variables. Example: “To reload the grant tables, use the
FLUSH PRIVILEGES statement.”
• Text in this style indicates input that you type in examples.
• Text in this style indicates the names of executable programs and scripts, examples being
mysql (the MySQL command-line client program) and mysqld (the MySQL server executable).
• Text in this style is used for variable input for which you should substitute a value of your own
choosing.
• Text in this style is used for emphasis.
• Text in this style is used in table headings and to convey especially strong emphasis.
• Text in this style is used to indicate a program option that affects how the program is executed,
or that supplies information that is needed for the program to function in a certain way. Example: “The -host option (short form -h) tells the mysql client program the hostname or IP address of the MySQL
server that it should connect to”.
• File names and directory names are written like this: “The global my.cnf file is located in the /etc
directory.”
• Character sequences are written like this: “To specify a wildcard, use the ‘%’ character.”
When commands are shown that are meant to be executed from within a particular program, the prompt
shown preceding the command indicates which command to use. For example, shell> indicates a
command that you execute from your login shell, root-shell> is similar but should be executed as
root, and mysql> indicates a statement that you execute from the mysql client program:
shell> type a shell command here
root-shell> type a shell command as root here
mysql> type a mysql statement here
In some areas different systems may be distinguished from each other to show that commands should be
executed in two different environments. For example, while working with replication the commands might
be prefixed with master and slave:
master> type a mysql command on the replication master here
slave> type a mysql command on the replication slave here
The “shell” is your command interpreter. On Unix, this is typically a program such as sh, csh, or bash. On
Windows, the equivalent program is command.com or cmd.exe, typically run in a console window.
When you enter a command or statement shown in an example, do not type the prompt shown in the
example.
Database, table, and column names must often be substituted into statements. To indicate that such
substitution is necessary, this manual uses db_name, tbl_name, and col_name. For example, you might
see a statement like this:
3
Overview of the MySQL Database Management System
mysql> SELECT col_name FROM db_name.tbl_name;
This means that if you were to enter a similar statement, you would supply your own database, table, and
column names, perhaps like this:
mysql> SELECT author_name FROM biblio_db.author_list;
SQL keywords are not case-sensitive and may be written in any lettercase. This manual uses uppercase.
In syntax descriptions, square brackets (“[” and “]”) indicate optional words or clauses. For example, in the
following statement, IF EXISTS is optional:
DROP TABLE [IF EXISTS] tbl_name
When a syntax element consists of a number of alternatives, the alternatives are separated by vertical bars
(“|”). When one member from a set of choices may be chosen, the alternatives are listed within square
brackets (“[” and “]”):
TRIM([[BOTH | LEADING | TRAILING] [remstr] FROM] str)
When one member from a set of choices must be chosen, the alternatives are listed within braces (“{” and
“}”):
{DESCRIBE | DESC} tbl_name [col_name | wild]
An ellipsis (...) indicates the omission of a section of a statement, typically to provide a shorter version of
more complex syntax. For example, SELECT ... INTO OUTFILE is shorthand for the form of SELECT
statement that has an INTO OUTFILE clause following other parts of the statement.
An ellipsis can also indicate that the preceding syntax element of a statement may be repeated. In
the following example, multiple reset_option values may be given, with each of those after the first
preceded by commas:
RESET reset_option [,reset_option] ...
Commands for setting shell variables are shown using Bourne shell syntax. For example, the sequence to
set the CC environment variable and run the configure command looks like this in Bourne shell syntax:
shell> CC=gcc ./configure
If you are using csh or tcsh, you must issue commands somewhat differently:
shell> setenv CC gcc
shell> ./configure
1.3 Overview of the MySQL Database Management System
1.3.1 What is MySQL?
4
What is MySQL?
MySQL, the most popular Open Source SQL database management system, is developed, distributed, and
supported by Oracle Corporation.
The MySQL website (http://www.mysql.com/) provides the latest information about MySQL software.
• MySQL is a database management system.
A database is a structured collection of data. It may be anything from a simple shopping list to a picture
gallery or the vast amounts of information in a corporate network. To add, access, and process data
stored in a computer database, you need a database management system such as MySQL Server.
Since computers are very good at handling large amounts of data, database management systems play
a central role in computing, as standalone utilities, or as parts of other applications.
• MySQL databases are relational.
A relational database stores data in separate tables rather than putting all the data in one big storeroom.
The database structures are organized into physical files optimized for speed. The logical model,
with objects such as databases, tables, views, rows, and columns, offers a flexible programming
environment. You set up rules governing the relationships between different data fields, such as one-toone, one-to-many, unique, required or optional, and “pointers” between different tables. The database
enforces these rules, so that with a well-designed database, your application never sees inconsistent,
duplicate, orphan, out-of-date, or missing data.
The SQL part of “MySQL” stands for “Structured Query Language”. SQL is the most common
standardized language used to access databases. Depending on your programming environment, you
might enter SQL directly (for example, to generate reports), embed SQL statements into code written in
another language, or use a language-specific API that hides the SQL syntax.
SQL is defined by the ANSI/ISO SQL Standard. The SQL standard has been evolving since 1986 and
several versions exist. In this manual, “SQL-92” refers to the standard released in 1992, “SQL:1999”
refers to the standard released in 1999, and “SQL:2003” refers to the current version of the standard. We
use the phrase “the SQL standard” to mean the current version of the SQL Standard at any time.
• MySQL software is Open Source.
Open Source means that it is possible for anyone to use and modify the software. Anybody can
download the MySQL software from the Internet and use it without paying anything. If you wish, you
may study the source code and change it to suit your needs. The MySQL software uses the GPL (GNU
General Public License), http://www.fsf.org/licenses/, to define what you may and may not do with the
software in different situations. If you feel uncomfortable with the GPL or need to embed MySQL code
into a commercial application, you can buy a commercially licensed version from us. See the MySQL
Licensing Overview for more information (http://www.mysql.com/company/legal/licensing/).
• The MySQL Database Server is very fast, reliable, scalable, and easy to use.
If that is what you are looking for, you should give it a try. MySQL Server can run comfortably on a
desktop or laptop, alongside your other applications, web servers, and so on, requiring little or no
attention. If you dedicate an entire machine to MySQL, you can adjust the settings to take advantage
of all the memory, CPU power, and I/O capacity available. MySQL can also scale up to clusters of
machines, networked together.
MySQL Server was originally developed to handle large databases much faster than existing solutions
and has been successfully used in highly demanding production environments for several years.
Although under constant development, MySQL Server today offers a rich and useful set of functions.
Its connectivity, speed, and security make MySQL Server highly suited for accessing databases on the
Internet.
5
The Main Features of MySQL
• MySQL Server works in client/server or embedded systems.
The MySQL Database Software is a client/server system that consists of a multithreaded SQL server
that supports different back ends, several different client programs and libraries, administrative tools, and
a wide range of application programming interfaces (APIs).
We also provide MySQL Server as an embedded multithreaded library that you can link into your
application to get a smaller, faster, easier-to-manage standalone product.
• A large amount of contributed MySQL software is available.
MySQL Server has a practical set of features developed in close cooperation with our users. It is very
likely that your favorite application or language supports the MySQL Database Server.
The official way to pronounce “MySQL” is “My Ess Que Ell” (not “my sequel”), but we do not mind if you
pronounce it as “my sequel” or in some other localized way.
1.3.2 The Main Features of MySQL
This section describes some of the important characteristics of the MySQL Database Software. In most
respects, the roadmap applies to all versions of MySQL. For information about features as they are
introduced into MySQL on a series-specific basis, see the “In a Nutshell” section of the appropriate Manual:
• MySQL 8.0: What Is New in MySQL 8.0
• MySQL 5.7: What Is New in MySQL 5.7
• MySQL 5.6: Section 1.4, “What Is New in MySQL 5.6”
• MySQL 5.5: What Is New in MySQL 5.5
Internals and Portability
• Written in C and C++.
• Tested with a broad range of different compilers.
• Works on many different platforms. See https://www.mysql.com/support/supportedplatforms/
database.html.
• For portability, uses CMake in MySQL 5.5 and up. Previous series use GNU Automake, Autoconf, and
Libtool.
• Tested with Purify (a commercial memory leakage detector) as well as with Valgrind, a GPL tool (http://
developer.kde.org/~sewardj/).
• Uses multi-layered server design with independent modules.
• Designed to be fully multithreaded using kernel threads, to easily use multiple CPUs if they are available.
• Provides transactional and nontransactional storage engines.
• Uses very fast B-tree disk tables (MyISAM) with index compression.
• Designed to make it relatively easy to add other storage engines. This is useful if you want to provide an
SQL interface for an in-house database.
6
The Main Features of MySQL
• Uses a very fast thread-based memory allocation system.
• Executes very fast joins using an optimized nested-loop join.
• Implements in-memory hash tables, which are used as temporary tables.
• Implements SQL functions using a highly optimized class library that should be as fast as possible.
Usually there is no memory allocation at all after query initialization.
• Provides the server as a separate program for use in a client/server networked environment, and as a
library that can be embedded (linked) into standalone applications. Such applications can be used in
isolation or in environments where no network is available.
Data Types
• Many data types: signed/unsigned integers 1, 2, 3, 4, and 8 bytes long, FLOAT, DOUBLE, CHAR,
VARCHAR, BINARY, VARBINARY, TEXT, BLOB, DATE, TIME, DATETIME, TIMESTAMP, YEAR, SET, ENUM,
and OpenGIS spatial types. See Chapter 11, Data Types.
• Fixed-length and variable-length string types.
Statements and Functions
• Full operator and function support in the SELECT list and WHERE clause of queries. For example:
mysql> SELECT CONCAT(first_name, ' ', last_name)
-> FROM citizen
-> WHERE income/dependents > 10000 AND age > 30;
• Full support for SQL GROUP BY and ORDER BY clauses. Support for group functions (COUNT(), AVG(),
STD(), SUM(), MAX(), MIN(), and GROUP_CONCAT()).
• Support for LEFT OUTER JOIN and RIGHT OUTER JOIN with both standard SQL and ODBC syntax.
• Support for aliases on tables and columns as required by standard SQL.
• Support for DELETE, INSERT, REPLACE, and UPDATE to return the number of rows that were changed
(affected), or to return the number of rows matched instead by setting a flag when connecting to the
server.
• Support for MySQL-specific SHOW statements that retrieve information about databases, storage
engines, tables, and indexes. Support for the INFORMATION_SCHEMA database, implemented according
to standard SQL.
• An EXPLAIN statement to show how the optimizer resolves a query.
• Independence of function names from table or column names. For example, ABS is a valid column name.
The only restriction is that for a function call, no spaces are permitted between the function name and
the “(” that follows it. See Section 9.3, “Keywords and Reserved Words”.
• You can refer to tables from different databases in the same statement.
Security
• A privilege and password system that is very flexible and secure, and that enables host-based
verification.
• Password security by encryption of all password traffic when you connect to a server.
7
The Main Features of MySQL
Scalability and Limits
• Support for large databases. We use MySQL Server with databases that contain 50 million records. We
also know of users who use MySQL Server with 200,000 tables and about 5,000,000,000 rows.
• Support for up to 64 indexes per table. Each index may consist of 1 to 16 columns or parts of columns.
The maximum index width for InnoDB tables is either 767 bytes or 3072 bytes. See Section 14.6.1.7,
“Limits on InnoDB Tables”. The maximum index width for MyISAM tables is 1000 bytes. See
Section 15.2, “The MyISAM Storage Engine”. An index may use a prefix of a column for CHAR, VARCHAR,
BLOB, or TEXT column types.
Connectivity
• Clients can connect to MySQL Server using several protocols:
• Clients can connect using TCP/IP sockets on any platform.
• On Windows systems, clients can connect using named pipes if the server is started with the -enable-named-pipe option. Windows servers also support shared-memory connections if started
with the --shared-memory option. Clients can connect through shared memory by using the -protocol=memory option.
• On Unix systems, clients can connect using Unix domain socket files.
• MySQL client programs can be written in many languages. A client library written in C is available for
clients written in C or C++, or for any language that provides C bindings.
• APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and Tcl are available, enabling MySQL clients to
be written in many languages. See Chapter 23, Connectors and APIs.
• The Connector/ODBC (MyODBC) interface provides MySQL support for client programs that use ODBC
(Open Database Connectivity) connections. For example, you can use MS Access to connect to your
MySQL server. Clients can be run on Windows or Unix. Connector/ODBC source is available. All ODBC
2.5 functions are supported, as are many others. See MySQL Connector/ODBC Developer Guide.
• The Connector/J interface provides MySQL support for Java client programs that use JDBC connections.
Clients can be run on Windows or Unix. Connector/J source is available. See MySQL Connector/J 5.1
Developer Guide.
• MySQL Connector/NET enables developers to easily create .NET applications that require secure,
high-performance data connectivity with MySQL. It implements the required ADO.NET interfaces and
integrates into ADO.NET aware tools. Developers can build applications using their choice of .NET
languages. MySQL Connector/NET is a fully managed ADO.NET driver written in 100% pure C#. See
MySQL Connector/NET Developer Guide.
Localization
• The server can provide error messages to clients in many languages. See Section 10.11, “Setting the
Error Message Language”.
• Full support for several different character sets, including latin1 (cp1252), german, big5, ujis,
several Unicode character sets, and more. For example, the Scandinavian characters “å”, “ä” and “ö” are
permitted in table and column names.
• All data is saved in the chosen character set.
• Sorting and comparisons are done according to the default character set and collation. is possible
to change this when the MySQL server is started (see Section 10.3.2, “Server Character Set and
8
History of MySQL
Collation”). To see an example of very advanced sorting, look at the Czech sorting code. MySQL Server
supports many different character sets that can be specified at compile time and runtime.
• The server time zone can be changed dynamically, and individual clients can specify their own time
zone. See Section 5.1.12, “MySQL Server Time Zone Support”.
Clients and Tools
• MySQL includes several client and utility programs. These include both command-line programs such as
mysqldump and mysqladmin, and graphical programs such as MySQL Workbench.
• MySQL Server has built-in support for SQL statements to check, optimize, and repair tables. These
statements are available from the command line through the mysqlcheck client. MySQL also includes
myisamchk, a very fast command-line utility for performing these operations on MyISAM tables. See
Chapter 4, MySQL Programs.
• MySQL programs can be invoked with the --help or -? option to obtain online assistance.
1.3.3 History of MySQL
We started out with the intention of using the mSQL database system to connect to our tables using our
own fast low-level (ISAM) routines. However, after some testing, we came to the conclusion that mSQL was
not fast enough or flexible enough for our needs. This resulted in a new SQL interface to our database but
with almost the same API interface as mSQL. This API was designed to enable third-party code that was
written for use with mSQL to be ported easily for use with MySQL.
MySQL is named after co-founder Monty Widenius's daughter, My.
The name of the MySQL Dolphin (our logo) is “Sakila,” which was chosen from a huge list of names
suggested by users in our “Name the Dolphin” contest. The winning name was submitted by Ambrose
Twebaze, an Open Source software developer from Swaziland, Africa. According to Ambrose, the feminine
name Sakila has its roots in SiSwati, the local language of Swaziland. Sakila is also the name of a town in
Arusha, Tanzania, near Ambrose's country of origin, Uganda.
1.4 What Is New in MySQL 5.6
This section summarizes what has been added to, deprecated in, and removed from MySQL 5.6.
• Features Added in MySQL 5.6
• Features Deprecated in MySQL 5.6
• Features Removed in MySQL 5.6
Features Added in MySQL 5.6
The following features have been added to MySQL 5.6:
• Security improvements.
These security improvements were made:
• 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.cnf file using encryption so the credentials are not
9
Features Added in MySQL 5.6
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
Section 4.6.6, “mysql_config_editor — MySQL Configuration Utility”.
• MySQL now supports stronger encryption for user account passwords, available through an
authentication plugin named sha256_password that 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 Section 6.5.1.4,
“SHA-256 Pluggable Authentication”.
• The mysql.user table now has a password_expired column. Its default value is 'N', but can
be set to 'Y' with the new ALTER USER statement. After an account's password has been expired,
all operations performed in subsequent connections to the server using the account result in an error
until the user issues a SET PASSWORD statement to establish a new account password. For more
information, see Section 13.7.1.1, “ALTER USER Syntax”, and Section 6.3.6, “Password Expiration
and Sandbox Mode”.
• 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_PASSWORD error). This affects the CREATE USER, GRANT, and SET PASSWORD
statements. Passwords given as arguments to the PASSWORD() and OLD_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_password plugin. For more information, see
Section 6.5.3, “The Password Validation Plugin”.
• 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 Section 6.1.2.4, “Password Hashing in MySQL”
• On Unix platforms, mysql_install_db supports a new option, --random-passwords, that
provides for more secure MySQL installation. Invoking mysql_install_db with --randompasswords causes it to assign a random password to the MySQL root accounts, set the “password
expired” flag for those accounts, and remove the anonymous-user MySQL accounts. For additional
details, see Section 4.4.3, “mysql_install_db — Initialize MySQL Data Directory”.
• Logging has been modified so that passwords do not appear in plain text in statements written to the
general query log, slow query log, and binary log. See Section 6.1.2.3, “Passwords and Logging”.
The mysql client no longer logs to its history file statements that refer to passwords. See
Section 4.5.1.3, “mysql Logging”.
• START SLAVE syntax has been modified to permit connection parameters to be specified for
connecting to the master. This provides an alternative to storing the password in the master.info
file. See Section 13.4.2.5, “START SLAVE Syntax”.
• MySQL Enterprise.
The format of the file generated by the audit log plugin was changed for better
compatibility with Oracle Audit Vault. See Section 6.5.4, “MySQL Enterprise Audit”, and Section 6.5.4.3,
“Audit Log File Formats”.
10
Features Added in MySQL 5.6
MySQL Enterprise Edition now includes a set of encryption functions based on the OpenSSL library
that expose OpenSSL capabilities at the SQL level. These functions enable Enterprise applications to
perform the following operations:
• Implement added data protection using public-key asymmetric cryptography
• Create public and private keys and digital signatures
• Perform asymmetric encryption and decryption
• Use cryptographic hashing for digital signing and data verification and validation
For more information, see Section 12.17, “MySQL Enterprise Encryption Functions”.
The audit log plugin included in MySQL Enterprise Edition now has the capability of filtering audited
events based on user account and event status. Several new system variables provide DBAs with
filtering control. In addition, audit log plugin reporting capability has been improved by the addition of
several status variables. For more information, see Section 6.5.4.4, “Audit Log Logging Control”, and
Audit Log Plugin Status Variables.
MySQL Enterprise Edition now includes MySQL Enterprise Firewall, an application-level firewall that
enables database administrators to permit or deny SQL statement execution based on matching against
whitelists of accepted statement patterns. This helps harden MySQL Server against attacks such as
SQL injection or attempts to exploit applications by using them outside of their legitimate query workload
characteristics. For more information, see Section 6.5.5, “MySQL Enterprise Firewall”.
• Changes to server defaults.
Beginning with MySQL 5.6.6, several MySQL Server parameter
defaults differ from the defaults in previous releases. 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. For more information, see Section 5.1.2.1, “Changes to Server Defaults”.
• InnoDB enhancements.
These InnoDB enhancements were added:
• You can create FULLTEXT indexes on InnoDB tables, and query them using the MATCH() ...
AGAINST syntax. This feature includes a new proximity search operator (@) and several new
configuration options and INFORMATION_SCHEMA tables: See Section 14.6.2.3, “InnoDB FULLTEXT
Indexes” for more information.
• Several ALTER TABLE operations can be performed without copying the table, without blocking
inserts, updates, and deletes to the table, or both. These enhancements are known collectively as
online DDL. See Section 14.13, “InnoDB and Online DDL” for details.
• InnoDB now supports the DATA DIRECTORY='directory' clause of the CREATE TABLE
statement, which allows you to create InnoDB file-per-table tablespaces (.ibd files) in a location
outside the MySQL data directory. This enhancement provides the flexibility to create file-per-table
tablespaces in locations that better suit your server environment. For example, you could place busy
tables on an SSD device, or large tables on a high-capacity HDD device.
For additional information, see Section 14.6.3.4, “Creating a Tablespace Outside of the Data
Directory”.
• InnoDB now supports the notion of “transportable tablespaces”, allowing file-per-table tablespaces
(.ibd files) to be exported from a running MySQL instance and imported into another running
instance without inconsistencies or mismatches caused by buffered data, in-progress transactions,
and internal bookkeeping details such as the space ID and LSN.
11
Features Added in MySQL 5.6
The FOR EXPORT clause of the FLUSH TABLE command writes any unsaved changes from InnoDB
memory buffers to the .ibd file. After copying the .ibd file and a separate metadata file to the
other server, the DISCARD TABLESPACE and IMPORT TABLESPACE clauses of the ALTER TABLE
statement are used to bring the table data into a different MySQL instance.
This enhancement provides the flexibility to move file-per-table tablespaces around to better suit your
server environment. For example, you could move busy tables to an SSD device, or move large tables
to a high-capacity HDD device. For more information, see Section 14.6.3.5, “Copying File-Per-Table
Tablespaces to Another Instance”.
• You can now set the InnoDB page size for uncompressed tables to 8KB or 4KB, as an alternative
to the default 16KB. This setting is controlled by the innodb_page_size configuration option. You
specify the size when creating the MySQL instance. All InnoDB tablespaces within an instance share
the same page size. Smaller page sizes can help to avoid redundant or inefficient I/O for certain
combinations of workload and storage devices, particularly SSD devices with small block sizes.
• Improvements to the algorithms for adaptive flushing make I/O operations more efficient and
consistent under a variety of workloads. The new algorithm and default configuration values are
expected to improve performance and concurrency for most users. Advanced users can fine-tune their
I/O responsiveness through several configuration options. See Section 14.8.3.5, “Fine-tuning InnoDB
Buffer Pool Flushing” for details.
• You can code MySQL applications that access InnoDB tables through a NoSQL-style API. This
feature uses the popular memcached daemon to relay requests such as ADD, SET, and GET for keyvalue pairs. These simple operations to store and retrieve data avoid the SQL overhead such as
parsing and constructing a query execution plan. You can access the same data through the NoSQL
API and SQL. For example, you might use the NoSQL API for fast updates and lookups, and SQL for
complex queries and compatibility with existing applications. See Section 14.20, “InnoDB memcached
Plugin” for details.
• Optimizer statistics for InnoDB tables are gathered at more predictable intervals and can persist
across server restarts, for improved plan stability. You can also control the amount of sampling done
for InnoDB indexes, to make the optimizer statistics more accurate and improve the query execution
plan. See Section 14.8.10.1, “Configuring Persistent Optimizer Statistics Parameters” for details.
• New optimizations apply to read-only transactions, improving performance and concurrency for adhoc queries and report-generating applications. These optimizations are applied automatically when
practical, or you can specify START TRANSACTION READ ONLY to ensure the transaction is readonly. See Section 8.5.3, “Optimizing InnoDB Read-Only Transactions” for details.
• You can move the InnoDB undo log out of the system tablespace into one or more separate
tablespaces. The I/O patterns for the undo log make these new tablespaces good candidates to
move to SSD storage, while keeping the system tablespace on hard disk storage. For details, see
Section 14.6.3.3, “Undo Tablespaces”.
• You can improve the efficiency of the InnoDB checksum feature by specifying the configuration option
innodb_checksum_algorithm=crc32, which turns on a faster checksum algorithm. This option
replaces the innodb_checksums option. Data written using the old checksum algorithm (option
value innodb) is fully upward-compatible; tablespaces modified using the new checksum algorithm
(option value crc32) cannot be downgraded to an earlier version of MySQL that does not support the
innodb_checksum_algorithm option.
• The InnoDB redo log files now have a maximum combined size of 512GB, increased from 4GB. You
can specify the larger values through the innodb_log_file_size option. The startup behavior now
12
Features Added in MySQL 5.6
automatically handles the situation where the size of the existing redo log files does not match the size
specified by innodb_log_file_size and innodb_log_files_in_group.
• The --innodb-read-only option lets you run a MySQL server in read-only mode. You can access
InnoDB tables on read-only media such as a DVD or CD, or set up a data warehouse with multiple
instances all sharing the same data directory. See Section 14.8.2, “Configuring InnoDB for Read-Only
Operation” for usage details.
• A new configuration option, innodb_compression_level, allows you to select a compression
level for InnoDB compressed tables, from the familiar range of 0-9 used by zlib. You can
also control whether compressed pages in the buffer pool are stored in the redo log when an
update operation causes pages to be compressed again. This behavior is controlled by the
innodb_log_compressed_pages configuration option.
• Data blocks in an InnoDB compressed table contain a certain amount of empty space (padding)
to allow DML operations to modify the row data without re-compressing the new values. Too much
padding can increase the chance of a compression failure, requiring a page split, when the data does
need to be re-compressed after extensive changes. The amount of padding can now be adjusted
dynamically, so that DBAs can reduce the rate of compression failures without re-creating the
entire table with new parameters, or re-creating the entire instance with a different page size. The
associated new configuration options are innodb_compression_failure_threshold_pct,
innodb_compression_pad_pct_max.
• Several new InnoDB-related INFORMATION_SCHEMA tables provide information about the InnoDB
buffer pool, metadata about tables, indexes, and foreign keys from the InnoDB data dictionary,
and low-level information about performance metrics that complements the information from the
Performance Schema tables.
• To ease the memory load on systems with huge numbers of tables, InnoDB now frees up the memory
associated with an opened table using an LRU algorithm to select tables that have gone the longest
without being accessed. To reserve more memory to hold metadata for open InnoDB tables, increase
the value of the table_definition_cache configuration option. InnoDB treats this value as a
“soft limit” for the number of open table instances in the InnoDB data dictionary cache. For additional
information, refer to the table_definition_cache documentation.
• InnoDB has several internal performance enhancements, including reducing contention by splitting
the kernel mutex, moving flushing operations from the main thread to a separate thread, enabling
multiple purge threads, and reducing contention for the buffer pool on large-memory systems.
• InnoDB uses a new, faster algorithm to detect deadlocks. Information about all InnoDB deadlocks
can be written to the MySQL server error log, to help diagnose application issues.
• To avoid a lengthy warmup period after restarting the server, particularly for instances with large
InnoDB buffer pools, you can reload pages into the buffer pool immediately after a restart. MySQL
can dump a compact data file at shutdown, then consult that data file to find the pages to reload
on the next restart. You can also manually dump or reload the buffer pool at any time, for example
during benchmarking or after complex report-generation queries. See Section 14.8.3.6, “Saving and
Restoring the Buffer Pool State” for details.
• As of MySQL 5.6.16, innochecksum provides support for files greater than 2GB in size. Previously,
innochecksum only supported files up to 2GB in size.
• As of MySQL 5.6.16, new global configuration parameters, innodb_status_output and
innodb_status_output_locks, allow you to dynamically enable and disable the standard InnoDB
Monitor and InnoDB Lock Monitor for periodic output. Enabling and disabling monitors for periodic
13
Features Added in MySQL 5.6
output by creating and dropping specially named tables is deprecated and may be removed in a future
release. For additional information, see Section 14.17, “InnoDB Monitors”.
• As of MySQL 5.6.17, Online DDL support is extended to the following operations for regular and
partitioned InnoDB tables:
• OPTIMIZE TABLE
• ALTER TABLE ... FORCE
• ALTER TABLE ... ENGINE=INNODB (when run on an InnoDB table)
Online DDL support reduces table rebuild time and permits concurrent DML. See Section 14.13,
“InnoDB and Online DDL”.
• As of MySQL 5.6.42, the zlib library version bundled with MySQL was raised from version 1.2.3 to
version 1.2.11. MySQL implements compression with the help of the zlib library.
If you use InnoDB compressed tables, see Section 2.11.1.3, “Changes in MySQL 5.6” for related
upgrade implications.
• Partitioning.
These table-partitioning enhancements were added:
• The maximum number of partitions is increased to 8192. This number includes all partitions and all
subpartitions of the table.
• It is now possible to exchange a partition of a partitioned table or a subpartition of a subpartitioned
table with a nonpartitioned table that otherwise has the same structure using the ALTER TABLE ...
EXCHANGE PARTITION statement. This can be used, for example, to import and export partitions. For
more information and examples, see Section 19.3.3, “Exchanging Partitions and Subpartitions with
Tables”.
• Explicit selection of one or more partitions or subpartitions is now supported for queries, as well as
for many data modification statements, that act on partitioned tables. For example, assume a table t
with some integer column c has 4 partitions named p0, p1, p2, and p3. Then the query SELECT *
FROM t PARTITION (p0, p1) WHERE c < 5 returns only those rows from partitions p0 and p1
for which c is less than 5.
The following statements support explicit partition selection:
• SELECT
• DELETE
• INSERT
• REPLACE
• UPDATE
• LOAD DATA.
• LOAD XML.
For syntax, see the descriptions of the individual statements. For additional information and examples,
see Section 19.5, “Partition Selection”.
14
Features Added in MySQL 5.6
• Partition lock pruning greatly improves performance of many DML and DDL statements acting on
tables with many partitions by helping to eliminate locks on partitions that are not affected by these
statements. Such statements include many SELECT, SELECT ... PARTITION, UPDATE, REPLACE,
INSERT, as well as many other statements. For more information, including a complete listing of
the statements whose performance has thus been improved, see Section 19.6.4, “Partitioning and
Locking”.
• Performance Schema.
The Performance Schema includes several new features:
• Instrumentation for table input and output. Instrumented operations include row-level accesses to
persistent base tables or temporary tables. Operations that affect rows are fetch, insert, update, and
delete.
• Event filtering by table, based on schema and/or table names.
• Event filtering by thread. More information is collected for threads.
• Summary tables for table and index I/O, and for table locks.
• Instrumentation for statements and stages within statements.
• Configuration of instruments and consumers at server startup, which previously was possible only at
runtime.
• MySQL NDB Cluster.
MySQL NDB Cluster is released as a separate product; the most recent GA
releases are based on MySQL 5.6 and use version 7.3 of the NDB storage engine. Clustering support is
not available in mainline MySQL Server 5.6 releases. For more information about MySQL NDB Cluster
7.3, see Chapter 18, MySQL NDB Cluster 7.3 and NDB Cluster 7.4. The latest current development
version is MySQL NDB Cluster 7.4, based on version 7.4 of the NDB storage engine and MySQL Server
5.6. MySQL NDB Cluster 7.4 is currently available for testing and evaluation. The most recent MySQL
NDB Cluster 7.4 release can be obtained from https://dev.mysql.com/downloads/cluster/.
For more information and an overview of improvements made in MySQL NDB Cluster 7.4, see
Section 18.1.4.2, “What is New in NDB Cluster 7.4”.
MySQL NDB Cluster 7.2, the previous GA release, is based on MySQL Server 5.5, and is still available
for use in production, although we recommend that new deployments use MySQL NDB Cluster 7.3. For
more information about MySQL NDB Cluster 7.2, see MySQL NDB Cluster 7.2.
MySQL NDB Cluster 7.1 is also still available and supported (although we recommend that new
deployments use the latest GA release series, currently MySQL NDB Cluster 7.3). These versions of
NDB Cluster are based on MySQL Server 5.1 and documented in the MySQL 5.1 Manual; see https://
dev.mysql.com/doc/refman/5.1/en/mysql-cluster.html, for more information.
• Replication and logging.
These replication enhancements were added:
• MySQL now supports transaction-based replication using global transaction identifiers (also known
as “GTIDs”). This makes it possible to identify and track each transaction when it is committed on the
originating server and as it is applied by any slaves.
Enabling of GTIDs in a replication setup is done primarily using the new --gtid-mode and -enforce-gtid-consistency server options. For information about additional options and variables
introduced in support of GTIDs, see Section 17.1.4.5, “Global Transaction ID Options and Variables”.
When using GTIDs it is not necessary to refer to log files or positions within those files when starting
a new slave or failing over to a new master, which greatly simplifies these tasks. For more information
15
Features Added in MySQL 5.6
about provisioning servers for GTID replication with or without referring to binary log files, see
Section 17.1.3.3, “Using GTIDs for Failover and Scaleout”.
GTID-based replication is completely transaction-based, which makes it simple to check the
consistency of masters and slaves. If all transactions committed on a given master are also committed
on a given slave, consistency between the two servers is guaranteed.
For more complete information about the implementation and use of GTIDs in MySQL Replication, see
Section 17.1.3, “Replication with Global Transaction Identifiers”.
• MySQL row-based replication now supports row image control. By logging only those columns
required for uniquely identifying and executing changes on each row (as opposed to all columns) for
each row change, it is possible to save disk space, network resources, and memory usage. You can
determine whether full or minimal rows are logged by setting the binlog_row_image server system
variable to one of the values minimal (log required columns only), full (log all columns), or noblob
(log all columns except for unneeded BLOB or TEXT columns). See System Variables Used with Binary
Logging, for more information.
• Binary logs written and read by the MySQL Server are now crash-safe, because only complete events
(or transactions) are logged or read back. By default, the server logs the length of the event as well
as the event itself and uses this information to verify that the event was written correctly. You can
also cause the server to write checksums for the events using CRC32 checksums by setting the
binlog_checksum system variable. To cause the server to read checksums from the binary log, use
the master_verify_checksum system variable. The --slave-sql-verify-checksum system
variable causes the slave SQL thread to read checksums from the relay log.
• MySQL now supports logging of master connection information and of slave relay log information to
tables as well as files. Use of these tables can be controlled independently, by the --master-inforepository and --relay-log-info-repository server options. Setting --master-inforepository to TABLE causes connection information to be logged in the slave_master_info
table; setting --relay-log-info-repository to TABLE causes relay log information to be logged
to the slave_relay_log_info table. Both of these tables are created automatically, in the mysql
system database.
In order for replication to be resilient to unexpected halts, the slave_master_info and
slave_relay_log_info tables must each use a transactional storage engine, and beginning with
MySQL 5.6.6, these tables are created using InnoDB for this reason. (Bug #13538891) If you are
using a previous MySQL 5.6 release in which both of these tables use MyISAM, this means that,
prior to starting replication, you must convert both of them to a transactional storage engine (such as
InnoDB) if you wish for replication to be resilient to unexpected halts. You can do this in such cases
by means of the appropriate ALTER TABLE ... ENGINE=... statements. You should not attempt
to change the storage engine used by either of these tables while replication is actually running.
See Section 17.3.2, “Handling an Unexpected Halt of a Replication Slave”, for more information.
• mysqlbinlog now has the capability to back up a binary log in its original binary format. When
invoked with the --read-from-remote-server and --raw options, mysqlbinlog connects
to a server, requests the log files, and writes output files in the same format as the originals. See
Section 4.6.8.3, “Using mysqlbinlog to Back Up Binary Log Files”.
• MySQL now supports delayed replication such that a slave server deliberately lags behind the master
by at least a specified amount of time. The default delay is 0 seconds. Use the new MASTER_DELAY
option for CHANGE MASTER TO to set the delay.
16
Features Added in MySQL 5.6
Delayed replication can be used for purposes such as protecting against user mistakes on the master
(a DBA can roll back a delayed slave to the time just before the disaster) or testing how the system
behaves when there is a lag. See Section 17.3.10, “Delayed Replication”.
• A replication slave having multiple network interfaces can now be caused to use only one of these (to
the exclusion of the others) by using the MASTER_BIND option when issuing a CHANGE MASTER TO
statement.
• The log_bin_basename system variable has been added. This variable contains the complete
filename and path to the binary log file. Whereas the log_bin system variable shows only whether or
not binary logging is enabled, log_bin_basename reflects the name set with the --log-bin server
option.
Similarly, the relay_log_basename system variable shows the filename and complete path to the
relay log file.
• MySQL Replication now supports parallel execution of transactions with multithreading on the slave.
When parallel execution is enabled, the slave SQL thread acts as the coordinator for a number of
slave worker threads as determined by the value of the slave_parallel_workers server system
variable. The current implementation of multithreading on the slave assumes that data and updates
are partitioned on a per-database basis, and that updates within a given database occur in the same
relative order as they do on the master. However, it is not necessary to coordinate transactions
between different databases. Transactions can then also be distributed per database, which means
that a worker thread on the slave slave can process successive transactions on a given database
without waiting for updates to other databases to complete.
Since transactions on different databases can occur in a different order on the slave than on the
master, simply checking for the most recently executed transaction is not a guarantee that all previous
transactions on the master have been executed on the slave. This has implications for logging and
recovery when using a multithreaded slave. For information about how to interpret binary logging
information when using multithreading on the slave, see Section 13.7.5.35, “SHOW SLAVE STATUS
Syntax”.
• Optimizer enhancements.
These query optimizer improvements were implemented:
• The optimizer now more efficiently handles queries (and subqueries) of the following form:
SELECT ... FROM single_table ... ORDER BY non_index_column [DESC] LIMIT [M,]N;
That type of query is common in web applications that display only a few rows from a larger result set.
For example:
SELECT col1, ... FROM t1 ... ORDER BY name LIMIT 10;
SELECT col1, ... FROM t1 ... ORDER BY RAND() LIMIT 15;
The sort buffer has a size of sort_buffer_size. If the sort elements for N rows are small enough to
fit in the sort buffer (M+N rows if M was specified), the server can avoid using a merge file and perform
the sort entirely in memory. For details, see Section 8.2.1.16, “LIMIT Query Optimization”.
• The optimizer implements Disk-Sweep Multi-Range Read. Reading rows using a range scan on
a secondary index can result in many random disk accesses to the base table when the table is
large and not stored in the storage engine's cache. With the Disk-Sweep Multi-Range Read (MRR)
optimization, MySQL tries to reduce the number of random disk access for range scans by first
scanning the index only and collecting the keys for the relevant rows. Then the keys are sorted and
17
Features Added in MySQL 5.6
finally the rows are retrieved from the base table using the order of the primary key. The motivation
for Disk-sweep MRR is to reduce the number of random disk accesses and instead achieve a more
sequential scan of the base table data. For more information, see Section 8.2.1.10, “Multi-Range Read
Optimization”.
• The optimizer implements Index Condition Pushdown (ICP), an optimization for the case where
MySQL retrieves rows from a table using an index. Without ICP, the storage engine traverses the
index to locate rows in the base table and returns them to the MySQL server which evaluates the
WHERE condition for the rows. With ICP enabled, and if parts of the WHERE condition can be evaluated
by using only fields from the index, the MySQL server pushes this part of the WHERE condition down to
the storage engine. The storage engine then evaluates the pushed index condition by using the index
entry and only if this is satisfied is base row be read. ICP can reduce the number of accesses the
storage engine has to do against the base table and the number of accesses the MySQL server has to
do against the storage engine. For more information, see Section 8.2.1.5, “Index Condition Pushdown
Optimization”.
• The EXPLAIN statement now provides execution plan information for DELETE, INSERT, REPLACE,
and UPDATE statements. Previously, EXPLAIN provided information only for SELECT statements.
In addition, the EXPLAIN statement now can produce output in JSON format. See Section 13.8.2,
“EXPLAIN Syntax”.
• The optimizer more efficiently handles subqueries in the FROM clause (that is, derived tables).
Materialization of subqueries in the FROM clause is postponed until their contents are needed during
query execution, which improves performance. In addition, during query execution, the optimizer
may add an index to a derived table to speed up row retrieval from it. For more information, see
Section 8.2.2.3, “Optimizing Derived Tables”.
• The optimizer uses semi-join and materialization strategies to optimize subquery execution. See
Section 8.2.2.1, “Optimizing Subqueries with Semi-Join Transformations”, and Section 8.2.2.2,
“Optimizing Subqueries with Materialization”.
• A Batched Key Access (BKA) join algorithm is now available that uses both index access to the joined
table and a join buffer. The BKA algorithm supports inner join, outer join, and semi-join operations,
including nested outer joins and nested semi-joins. Benefits of BKA include improved join performance
due to more efficient table scanning. For more information, see Section 8.2.1.11, “Block Nested-Loop
and Batched Key Access Joins”.
• The optimizer now has a tracing capability, primarily for use by developers. The
interface is provided by a set of optimizer_trace_xxx system variables and the
INFORMATION_SCHEMA.OPTIMIZER_TRACE table. For details, see MySQL Internals: Tracing the
Optimizer.
• Condition handling.
MySQL now supports the GET DIAGNOSTICS statement. GET DIAGNOSTICS
provides applications a standardized way to obtain information from the diagnostics area, such as
whether the previous SQL statement produced an exception and what it was. For more information, see
Section 13.6.7.3, “GET DIAGNOSTICS Syntax”.
In addition, several deficiencies in condition handler processing rules were corrected so that MySQL
behavior is more like standard SQL:
• Block scope is used in determining which handler to select. Previously, a stored program was treated
as having a single scope for handler selection.
• Condition precedence is more accurately resolved.
18
Features Added in MySQL 5.6
• Diagnostics area clearing has changed. Bug #55843 caused handled conditions to be cleared from
the diagnostics area before activating the handler. This made condition information unavailable within
the handler. Now condition information is available to the handler, which can inspect it with the GET
DIAGNOSTICS statement. The condition information is cleared when the handler exits, if it has not
already been cleared during handler execution.
• Previously, handlers were activated as soon as a condition occurred. Now they are not activated until
the statement in which the condition occurred finishes execution, at which point the most appropriate
handler is chosen. This can make a difference for statements that raise multiple conditions, if a
condition raised later during statement execution has higher precedence than an earlier condition and
there are handlers in the same scope for both conditions. Previously, the handler for the first condition
raised would be chosen, even if it had a lower precedence than other handlers. Now the handler
for the condition with highest precedence is chosen, even if it is not the first condition raised by the
statement.
For more information, see Section 13.6.7.6, “Scope Rules for Handlers”.
• Data types.
These data type changes have been implemented:
• MySQL now permits fractional seconds for TIME, DATETIME, and TIMESTAMP values, with up to
microseconds (6 digits) precision. See Section 11.3.6, “Fractional Seconds in Time Values”.
• Previously, at most one TIMESTAMP column per table could be automatically initialized or updated
to the current date and time. This restriction has been lifted. Any TIMESTAMP column definition can
have any combination of DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP
clauses. In addition, these clauses now can be used with DATETIME column definitions. For
more information, see Section 11.3.5, “Automatic Initialization and Updating for TIMESTAMP and
DATETIME”.
• In MySQL, the TIMESTAMP data type differs in nonstandard ways from other data types in
terms of default value and assignment of automatic initialization and update attributes. These
behaviors remain the default but now are deprecated, and can be turned off by enabling the
explicit_defaults_for_timestamp system variable at server startup. See Section 11.3.5,
“Automatic Initialization and Updating for TIMESTAMP and DATETIME”, and Section 5.1.7, “Server
System Variables”.
• Host cache.
MySQL now provides more information about the causes of errors that occur when
clients connect to the server, as well as improved access to the host cache, which contains client IP
address and host name information and is used to avoid DNS lookups. These changes have been
implemented:
• New Connection_errors_xxx status variables provide information about connection errors that do
not apply to specific client IP addresses.
• Counters have been added to the host cache to track errors that do apply to specific IP addresses,
and a new host_cache Performance Schema table exposes the contents of the host cache so that
it can be examined using SELECT statements. Access to host cache contents makes it possible to
answer questions such as how many hosts are cached, what kinds of connection errors are occurring
for which hosts, or how close host error counts are to reaching the max_connect_errors system
variable limit.
• The host cache size now is configurable using the host_cache_size system variable.
For more information, see Section 8.12.5.2, “DNS Lookup Optimization and the Host Cache”, and
Section 22.12.10.1, “The host_cache Table”.
19
Features Deprecated in MySQL 5.6
• OpenGIS.
The OpenGIS specification defines functions that test the relationship between two
geometry values. MySQL originally implemented these functions such that they used object bounding
rectangles and returned the same result as the corresponding MBR-based functions. Corresponding
versions are now available that use precise object shapes. These versions are named with an ST_
prefix. For example, Contains() uses object bounding rectangles, whereas ST_Contains() uses
object shapes. For more information, see Section 12.15.9, “Functions That Test Spatial Relations
Between Geometry Objects”.
Features Deprecated in MySQL 5.6
The following features are deprecated in MySQL 5.6 and may be or will be removed in a future series.
Where alternatives are shown, applications should be updated to use them.
For applications that use features deprecated in MySQL 5.6 that have been removed in a higher MySQL
series, statements may fail when replicated from a MySQL 5.6 master to a higher-series slave, or may
have different effects on master and slave. To avoid such problems, applications that use features
deprecated in 5.6 should be revised to avoid them and use alternatives when possible.
• The ERROR_FOR_DIVISION_BY_ZERO, NO_ZERO_DATE, and NO_ZERO_IN_DATE SQL modes are
deprecated and setting the sql_mode value to include any of them generates a warning. In MySQL
5.7, these modes do nothing. Instead, their effects are included in the effects of strict SQL mode
(STRICT_ALL_TABLES or STRICT_TRANS_TABLES). The motivation for the change in MySQL 5.7 is to
reduce the number of SQL modes with an effect dependent on strict mode and make them part of strict
mode itself.
To make advance preparation for an upgrade to MySQL 5.7, see SQL Mode Changes in MySQL 5.7.
That discussion provides guidelines to assess whether your applications will be affected by the SQL
mode changes in MySQL 5.7.
• Relying on implicit GROUP BY sorting in MySQL 5.6 is deprecated. To achieve a specific sort order of
grouped results, it is preferable to use an explicit ORDER BY clause. GROUP BY sorting is a MySQL
extension that may change in a future release; for example, to make it possible for the optimizer to order
groupings in whatever manner it deems most efficient and to avoid the sorting overhead.
• Pre-4.1 passwords and the mysql_old_password authentication plugin. Passwords stored in
the older hash format used before MySQL 4.1 are less secure than passwords that use the native
password hashing method and should be avoided. Pre-4.1 passwords and the mysql_old_password
authentication plugin are now deprecated. To prevent connections using accounts that have pre-4.1
password hashes, the secure_auth system variable is now enabled by default. (To permit connections
for accounts that have such password hashes, start the server with --secure_auth=0. However,
because pre-4.1 passwords are deprecated, disabling secure_auth is also deprecated.)
DBAs are advised to convert accounts that use the mysql_old_password authentication plugin to use
mysql_native_password instead. For account upgrade instructions, see Section 6.5.1.3, “Migrating
Away from Pre-4.1 Password Hashing and the mysql_old_password Plugin”.
The OLD_PASSWORD() function generates pre-4.1 password hashes, as does PASSWORD() if
the old_passwords system variable is set to 1. OLD_PASSWORD() and old_passwords=1 are
deprecated.
• The --skip-innodb option and its synonyms (--innodb=OFF, --disable-innodb, and so forth).
• The innodb_locks_unsafe_for_binlog system variable.
• The date_format, datetime_format, and time_format system variables, which are unused.
• The have_profiling, profiling, and profiling_history_size system variables.
20
Features Removed in MySQL 5.6
• The innodb_use_sys_malloc and innodb_additional_mem_pool_size system variables.
• The timed_mutexes system variable. It does nothing and has no effect.
• The --language option. Use the --lc-messages-dir and --lc-messages options instead.
• The IGNORE clause for ALTER TABLE. ALTER IGNORE TABLE causes problems for replication,
prevents online ALTER TABLE for unique index creation, and causes problems with foreign keys (rows
removed in the parent table).
• The msql2mysql, mysql_convert_table_format, mysql_find_rows,
mysql_fix_extensions, mysql_setpermission, mysql_waitpid, mysql_zap, mysqlaccess,
and mysqlbug utilities.
• The mysqlhotcopy utility. Alternatives include mysqldump and MySQL Enterprise Backup.
Features Removed in MySQL 5.6
The following items are obsolete and have been removed in MySQL 5.6. Where alternatives are shown,
applications should be updated to use them.
For MySQL 5.5 applications that use features removed in MySQL 5.6, statements may fail when replicated
from a MySQL 5.5 master to a MySQL 5.6 slave, or may have different effects on master and slave. To
avoid such problems, applications that use features removed in MySQL 5.6 should be revised to avoid
them and use alternatives when possible.
• The --log server option and the log system variable. Instead, use the --general_log option to
enable the general query log and the --general_log_file=file_name option to set the general
query log file name.
• The --log-slow-queries server option and the log_slow_queries system variable.
Instead, use the --slow_query_log option to enable the slow query log and the -slow_query_log_file=file_name option to set the slow query log file name.
• The --one-thread server option. Use --thread_handling=no-threads instead.
• The --safe-mode server option.
• The --skip-thread-priority server option.
• The --table-cache server option. Use the table_open_cache system variable instead.
• The --init-rpl-role and --rpl-recovery-rank options, the rpl_recovery_rank system
variable, and the Rpl_status status variable.
• The engine_condition_pushdown system variable. Use the engine_condition_pushdown flag
of the optimizer_switch variable instead.
• The have_csv, have_innodb, have_ndbcluster, and have_partitioning system variables. Use
SHOW PLUGINS or query the PLUGINS table in the INFORMATION_SCHEMA database instead.
• The sql_big_tables system variable. Use big_tables instead.
• The sql_low_priority_updates system variable. Use low_priority_updates instead.
• The sql_max_join_size system variable. Use max_join_size instead.
• The max_long_data_size system variable. Use max_allowed_packet instead.
21
MySQL Information Sources
• The FLUSH MASTER and FLUSH SLAVE statements. Use the RESET MASTER and RESET SLAVE
statements instead.
• The SLAVE START and SLAVE STOP statements. Use The START SLAVE and STOP SLAVE
statements.
• The SHOW AUTHORS and SHOW CONTRIBUTORS statements.
• The OPTION and ONE_SHOT modifiers for the SET statement.
• It is explicitly disallowed to assign the value DEFAULT to stored procedure or function parameters or
stored program local variables (for example with a SET var_name = DEFAULT statement). It remains
permissible to assign DEFAULT to system variables, as before.
• Most SHOW ENGINE INNODB MUTEX output is removed in 5.6.14. SHOW ENGINE INNODB MUTEX
output is removed entirely in MySQL 5.7.2. Comparable information can be generated by creating views
on Performance Schema tables.
1.5 MySQL Information Sources
This section lists sources of additional information that you may find helpful, such as MySQL websites,
mailing lists, user forums, and Internet Relay Chat.
1.5.1 MySQL Websites
The primary website for MySQL documentation is https://dev.mysql.com/doc/. Online and downloadable
documentation formats are available for the MySQL Reference Manual, MySQL Connectors, and more.
The MySQL developers provide information about new and upcoming features as the MySQL Server Blog.
1.5.2 MySQL Mailing Lists
This section introduces the MySQL mailing lists and provides guidelines as to how the lists should be used.
When you subscribe to a mailing list, you receive all postings to the list as email messages. You can also
send your own questions and answers to the list.
To subscribe to or unsubscribe from any of the mailing lists described in this section, visit http://
lists.mysql.com/. For most of them, you can select the regular version of the list where you get individual
messages, or a digest version where you get one large message per day.
Please do not send messages about subscribing or unsubscribing to any of the mailing lists, because such
messages are distributed automatically to thousands of other users.
Your local site may have many subscribers to a MySQL mailing list. If so, the site may have a local mailing
list, so that messages sent from lists.mysql.com to your site are propagated to the local list. In such
cases, please contact your system administrator to be added to or dropped from the local MySQL list.
To have traffic for a mailing list go to a separate mailbox in your mail program, set up a filter based on
the message headers. You can use either the List-ID: or Delivered-To: headers to identify list
messages.
The MySQL mailing lists are as follows:
• announce
The list for announcements of new versions of MySQL and related programs. This is a low-volume list to
which all MySQL users should subscribe.
22
MySQL Mailing Lists
• mysql
The main list for general MySQL discussion. Please note that some topics are better discussed on the
more-specialized lists. If you post to the wrong list, you may not get an answer.
• bugs
The list for people who want to stay informed about issues reported since the last release of MySQL
or who want to be actively involved in the process of bug hunting and fixing. See Section 1.6, “How to
Report Bugs or Problems”.
• internals
The list for people who work on the MySQL code. This is also the forum for discussions on MySQL
development and for posting patches.
• mysqldoc
The list for people who work on the MySQL documentation.
• benchmarks
The list for anyone interested in performance issues. Discussions concentrate on database performance
(not limited to MySQL), but also include broader categories such as performance of the kernel, file
system, disk system, and so on.
• packagers
The list for discussions on packaging and distributing MySQL. This is the forum used by distribution
maintainers to exchange ideas on packaging MySQL and on ensuring that MySQL looks and feels as
similar as possible on all supported platforms and operating systems.
• java
The list for discussions about the MySQL server and Java. It is mostly used to discuss JDBC drivers
such as MySQL Connector/J.
• win32
The list for all topics concerning the MySQL software on Microsoft operating systems, such as Windows
9x, Me, NT, 2000, XP, and 2003.
• myodbc
The list for all topics concerning connecting to the MySQL server with ODBC.
• gui-tools
The list for all topics concerning MySQL graphical user interface tools such as MySQL Workbench.
• cluster
The list for discussion of MySQL Cluster.
• dotnet
The list for discussion of the MySQL server and the .NET platform. It is mostly related to MySQL
Connector/NET.
23
MySQL Community Support at the MySQL Forums
• plusplus
The list for all topics concerning programming with the C++ API for MySQL.
• perl
The list for all topics concerning Perl support for MySQL with DBD::mysql.
If you're unable to get an answer to your questions from a MySQL mailing list or forum, one option is to
purchase support from Oracle. This puts you in direct contact with MySQL developers.
The following MySQL mailing lists are in languages other than English. These lists are not operated by
Oracle.
•
A French mailing list.
•
A Korean mailing list. To subscribe, email subscribe mysql your@email.address to this list.
•
A German mailing list. To subscribe, email subscribe mysql-de your@email.address to this list.
You can find information about this mailing list at http://www.4t2.com/mysql/.
•
A Portuguese mailing list. To subscribe, email subscribe mysql-br your@email.address to this
list.
•
A Spanish mailing list. To subscribe, email subscribe mysql your@email.address to this list.
1.5.2.1 Guidelines for Using the Mailing Lists
Please do not post mail messages from your browser with HTML mode turned on. Many users do not read
mail with a browser.
When you answer a question sent to a mailing list, if you consider your answer to have broad interest,
you may want to post it to the list instead of replying directly to the individual who asked. Try to make your
answer general enough that people other than the original poster may benefit from it. When you post to the
list, please make sure that your answer is not a duplication of a previous answer.
Try to summarize the essential part of the question in your reply. Do not feel obliged to quote the entire
original message.
When answers are sent to you individually and not to the mailing list, it is considered good etiquette to
summarize the answers and send the summary to the mailing list so that others may have the benefit of
responses you received that helped you solve your problem.
1.5.3 MySQL Community Support at the MySQL Forums
The forums at http://forums.mysql.com are an important community resource. Many forums are available,
grouped into these general categories:
24
MySQL Community Support on Internet Relay Chat (IRC)
• Migration
• MySQL Usage
• MySQL Connectors
• Programming Languages
• Tools
• 3rd-Party Applications
• Storage Engines
• MySQL Technology
• SQL Standards
• Business
1.5.4 MySQL Community Support on Internet Relay Chat (IRC)
In addition to the various MySQL mailing lists and forums, you can find experienced community people on
Internet Relay Chat (IRC). These are the best networks/channels currently known to us:
freenode (see http://www.freenode.net/ for servers)
• #mysql is primarily for MySQL questions, but other database and general SQL questions are welcome.
Questions about PHP, Perl, or C in combination with MySQL are also common.
• #workbench is primarily for MySQL Workbench related questions and thoughts, and it is also a good
place to meet the MySQL Workbench developers.
1.5.5 MySQL Enterprise
Oracle offers technical support in the form of MySQL Enterprise. For organizations that rely on the MySQL
DBMS for business-critical production applications, MySQL Enterprise is a commercial subscription
offering which includes:
• MySQL Enterprise Server
• MySQL Enterprise Monitor
• Monthly Rapid Updates and Quarterly Service Packs
• MySQL Knowledge Base
• 24x7 Technical and Consultative Support
MySQL Enterprise is available in multiple tiers, giving you the flexibility to choose the level of service that
best matches your needs. For more information, see MySQL Enterprise.
1.6 How to Report Bugs or Problems
Before posting a bug report about a problem, please try to verify that it is a bug and that it has not been
reported already:
• Start by searching the MySQL online manual at https://dev.mysql.com/doc/. We try to keep the manual
up to date by updating it frequently with solutions to newly found problems. In addition, the release
25
How to Report Bugs or Problems
notes accompanying the manual can be particularly useful since it is quite possible that a newer version
contains a solution to your problem. The release notes are available at the location just given for the
manual.
• If you get a parse error for an SQL statement, please check your syntax closely. If you cannot find
something wrong with it, it is extremely likely that your current version of MySQL Server doesn't support
the syntax you are using. If you are using the current version and the manual doesn't cover the syntax
that you are using, MySQL Server doesn't support your statement.
If the manual covers the syntax you are using, but you have an older version of MySQL Server, you
should check the MySQL change history to see when the syntax was implemented. In this case, you
have the option of upgrading to a newer version of MySQL Server.
• For solutions to some common problems, see Section B.5, “Problems and Common Errors”.
• Search the bugs database at http://bugs.mysql.com/ to see whether the bug has been reported and
fixed.
• Search the MySQL mailing list archives at http://lists.mysql.com/. See Section 1.5.2, “MySQL Mailing
Lists”.
• You can also use http://www.mysql.com/search/ to search all the Web pages (including the manual) that
are located at the MySQL website.
If you cannot find an answer in the manual, the bugs database, or the mailing list archives, check with your
local MySQL expert. If you still cannot find an answer to your question, please use the following guidelines
for reporting the bug.
The normal way to report bugs is to visit http://bugs.mysql.com/, which is the address for our bugs
database. This database is public and can be browsed and searched by anyone. If you log in to the
system, you can enter new reports.
Bugs posted in the bugs database at http://bugs.mysql.com/ that are corrected for a given release are
noted in the release notes.
If you find a sensitive security bug in MySQL Server, please let us know immediately by sending an email
message to . Exception: Support customers should report all problems,
including security bugs, to Oracle Support at http://support.oracle.com/.
To discuss problems with other users, you can use one of the MySQL mailing lists. Section 1.5.2, “MySQL
Mailing Lists”.
Writing a good bug report takes patience, but doing it right the first time saves time both for us and for
yourself. A good bug report, containing a full test case for the bug, makes it very likely that we will fix the
bug in the next release. This section helps you write your report correctly so that you do not waste your
time doing things that may not help us much or at all. Please read this section carefully and make sure that
all the information described here is included in your report.
Preferably, you should test the problem using the latest production or development version of MySQL
Server before posting. Anyone should be able to repeat the bug by just using mysql test <
script_file on your test case or by running the shell or Perl script that you include in the bug report.
Any bug that we are able to repeat has a high chance of being fixed in the next MySQL release.
It is most helpful when a good description of the problem is included in the bug report. That is, give a good
example of everything you did that led to the problem and describe, in exact detail, the problem itself.
The best reports are those that include a full example showing how to reproduce the bug or problem. See
Section 24.5, “Debugging and Porting MySQL”.
26
How to Report Bugs or Problems
Remember that it is possible for us to respond to a report containing too much information, but not to one
containing too little. People often omit facts because they think they know the cause of a problem and
assume that some details do not matter. A good principle to follow is that if you are in doubt about stating
something, state it. It is faster and less troublesome to write a couple more lines in your report than to wait
longer for the answer if we must ask you to provide information that was missing from the initial report.
The most common errors made in bug reports are (a) not including the version number of the MySQL
distribution that you use, and (b) not fully describing the platform on which the MySQL server is installed
(including the platform type and version number). These are highly relevant pieces of information, and in
99 cases out of 100, the bug report is useless without them. Very often we get questions like, “Why doesn't
this work for me?” Then we find that the feature requested wasn't implemented in that MySQL version,
or that a bug described in a report has been fixed in newer MySQL versions. Errors often are platformdependent. In such cases, it is next to impossible for us to fix anything without knowing the operating
system and the version number of the platform.
If you compiled MySQL from source, remember also to provide information about your compiler if it is
related to the problem. Often people find bugs in compilers and think the problem is MySQL-related.
Most compilers are under development all the time and become better version by version. To determine
whether your problem depends on your compiler, we need to know what compiler you used. Note that
every compiling problem should be regarded as a bug and reported accordingly.
If a program produces an error message, it is very important to include the message in your report. If we try
to search for something from the archives, it is better that the error message reported exactly matches the
one that the program produces. (Even the lettercase should be observed.) It is best to copy and paste the
entire error message into your report. You should never try to reproduce the message from memory.
If you have a problem with Connector/ODBC (MyODBC), please try to generate a trace file and send it with
your report. See How to Report Connector/ODBC Problems or Bugs.
If your report includes long query output lines from test cases that you run with the mysql commandline tool, you can make the output more readable by using the --vertical option or the \G statement
terminator. The EXPLAIN SELECT example later in this section demonstrates the use of \G.
Please include the following information in your report:
• The version number of the MySQL distribution you are using (for example, MySQL 5.7.10). You can find
out which version you are running by executing mysqladmin version. The mysqladmin program can
be found in the bin directory under your MySQL installation directory.
• The manufacturer and model of the machine on which you experience the problem.
• The operating system name and version. If you work with Windows, you can usually get the name and
version number by double-clicking your My Computer icon and pulling down the “Help/About Windows”
menu. For most Unix-like operating systems, you can get this information by executing the command
uname -a.
• Sometimes the amount of memory (real and virtual) is relevant. If in doubt, include these values.
• The contents of the docs/INFO_BIN file from your MySQL installation. This file contains information
about how MySQL was configured and compiled.
• If you are using a source distribution of the MySQL software, include the name and version number of
the compiler that you used. If you have a binary distribution, include the distribution name.
• If the problem occurs during compilation, include the exact error messages and also a few lines of
context around the offending code in the file where the error occurs.
27
How to Report Bugs or Problems
• If mysqld died, you should also report the statement that crashed mysqld. You can usually get this
information by running mysqld with query logging enabled, and then looking in the log after mysqld
crashes. See Section 24.5, “Debugging and Porting MySQL”.
• If a database table is related to the problem, include the output from the SHOW CREATE TABLE
db_name.tbl_name statement in the bug report. This is a very easy way to get the definition of
any table in a database. The information helps us create a situation matching the one that you have
experienced.
• The SQL mode in effect when the problem occurred can be significant, so please report the value of
the sql_mode system variable. For stored procedure, stored function, and trigger objects, the relevant
sql_mode value is the one in effect when the object was created. For a stored procedure or function,
the SHOW CREATE PROCEDURE or SHOW CREATE FUNCTION statement shows the relevant SQL mode,
or you can query INFORMATION_SCHEMA for the information:
SELECT ROUTINE_SCHEMA, ROUTINE_NAME, SQL_MODE
FROM INFORMATION_SCHEMA.ROUTINES;
For triggers, you can use this statement:
SELECT EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE, TRIGGER_NAME, SQL_MODE
FROM INFORMATION_SCHEMA.TRIGGERS;
• For performance-related bugs or problems with SELECT statements, you should always include the
output of EXPLAIN SELECT ..., and at least the number of rows that the SELECT statement produces.
You should also include the output from SHOW CREATE TABLE tbl_name for each table that is
involved. The more information you provide about your situation, the more likely it is that someone can
help you.
The following is an example of a very good bug report. The statements are run using the mysql
command-line tool. Note the use of the \G statement terminator for statements that would otherwise
provide very long output lines that are difficult to read.
mysql> SHOW VARIABLES;
mysql> SHOW COLUMNS FROM ...\G