2.7. Installing MySQL on HP-UX ......................................................................................................97
2.7.1. General Notes on Installing MySQL on HP-UX ......................................................................98
2.7.2. Installing MySQL on HP-UX using DEPOT ..........................................................................98
2.8. Installing MySQL on FreeBSD ....................................................................................................99
2.9. Installing MySQL from Source ....................................................................................................99
2.9.1. MySQL Layout for Source Installation ............................................................................... 101
2.9.2. Installing MySQL from a Standard Source Distribution ........................................................... 101
2.9.3. Installing MySQL from a Development Source Tree .............................................................. 104
2.9.4. MySQL Source-Configuration Options .............................................................................. 106
2.9.5. Dealing with Problems Compiling MySQL ......................................................................... 113
2.9.6. MySQL Configuration and Third-Party Tools ...................................................................... 114
2.10. Postinstallation Setup and Testing ............................................................................................. 114
2.10.1. Unix Postinstallation Procedures .................................................................................... 114
2.10.2. Securing the Initial MySQL Accounts .............................................................................. 124
2.11. Upgrading or Downgrading MySQL .......................................................................................... 127
2.11.1. Upgrading MySQL .................................................................................................... 127
2.11.2. Downgrading MySQL ................................................................................................. 130
2.11.3. Checking Whether Tables or Indexes Must Be Rebuilt ........................................................... 131
2.11.4. Rebuilding or Repairing Tables or Indexes ......................................................................... 132
2.11.5. Copying MySQL Databases to Another Machine ................................................................. 134
2.12. Environment Variables .......................................................................................................... 135
2.13. Perl Installation Notes ........................................................................................................... 136
2.13.1. Installing Perl on Unix ................................................................................................ 136
2.13.2. Installing ActiveState Perl on Windows ............................................................................ 137
2.13.3. Problems Using the Perl DBI/DBD Interface ....................................................................... 137
3. Tutorial ........................................................................................................................................ 139
3.1. Connecting to and Disconnecting from the Server ............................................................................ 139
3.2. Entering Queries ................................................................................................................... 140
3.3. Creating and Using a Database .................................................................................................. 142
3.3.1. Creating and Selecting a Database .................................................................................... 143
3.3.2. Creating a Table ......................................................................................................... 144
3.3.3. Loading Data into a Table .............................................................................................. 145
3.3.4. Retrieving Information from a Table ................................................................................. 146
3.4. Getting Information About Databases and Tables ............................................................................ 157
3.5. Using mysql in Batch Mode .................................................................................................... 158
3.6. Examples of Common Queries .................................................................................................. 159
3.6.1. The Maximum Value for a Column ................................................................................... 160
3.6.2. The Row Holding the Maximum of a Certain Column ............................................................. 160
3.6.3. Maximum of Column per Group ...................................................................................... 160
3.6.4. The Rows Holding the Group-wise Maximum of a Certain Column ............................................. 161
3.6.5. Using User-Defined Variables ......................................................................................... 161
3.6.6. Using Foreign Keys ..................................................................................................... 161
3.6.7. Searching on Two Keys ................................................................................................ 163
3.6.8. Calculating Visits Per Day ............................................................................................. 163
3.6.9. Using AUTO_INCREMENT ............................................................................................ 164
3.7. Using MySQL with Apache ...................................................................................................... 165
4. MySQL Programs ............................................................................................................................ 167
4.1. Overview of MySQL Programs .................................................................................................. 168
4.2. Using MySQL Programs .......................................................................................................... 172
4.2.1. Invoking MySQL Programs ............................................................................................ 172
4.2.2. Connecting to the MySQL Server ..................................................................................... 172
4.2.3. Specifying Program Options ........................................................................................... 175
4.2.4. Setting Environment Variables ........................................................................................ 186
4.3. MySQL Server and Server-Startup Programs .................................................................................. 187
4.3.1. mysqld — The MySQL Server ...................................................................................... 187
4.3.2. mysqld_safe — MySQL Server Startup Script ................................................................. 187
4.3.3. mysql.server — MySQL Server Startup Script ............................................................... 191
4.3.4. mysqld_multi — Manage Multiple MySQL Servers .......................................................... 192
4.4. MySQL Installation-Related Programs ......................................................................................... 195
4.4.1. comp_err — Compile MySQL Error Message File .............................................................. 195
4.4.2. mysqlbug — Generate Bug Report ................................................................................. 196
4.4.3. mysql_install_db — Initialize MySQL Data Directory .................................................... 196
4.4.4. mysql_plugin — Configure MySQL Server Plugins .......................................................... 197
4.4.5. mysql_secure_installation — Improve MySQL Installation Security .............................. 199
4.4.6. mysql_tzinfo_to_sql — Load the Time Zone Tables ..................................................... 199
MySQL 5.6 Reference Manual
v