
MySQL 5.5 Reference Manual
iv
2.4.5 Using the Bundled MySQL on Mac OS X Server ................................................ 136
2.5 Installing MySQL on Linux ........................................................................................... 136
2.5.1 Installing MySQL on Linux Using RPM Packages ............................................... 137
2.5.2 Installing MySQL on Linux Using Debian Packages ............................................ 142
2.5.3 Installing MySQL on Linux Using Native Package Managers ............................... 142
2.6 Installing MySQL Using Unbreakable Linux Network (ULN) ............................................ 146
2.7 Installing MySQL on Solaris and OpenSolaris ............................................................... 146
2.7.1 Installing MySQL on Solaris Using a Solaris PKG ............................................... 147
2.7.2 Installing MySQL on OpenSolaris Using IPS ...................................................... 148
2.8 Installing MySQL on FreeBSD ..................................................................................... 149
2.9 Installing MySQL from Source ...................................................................................... 150
2.9.1 MySQL Layout for Source Installation ................................................................ 152
2.9.2 Installing MySQL Using a Standard Source Distribution ...................................... 152
2.9.3 Installing MySQL Using a Development Source Tree .......................................... 156
2.9.4 MySQL Source-Configuration Options ................................................................ 157
2.9.5 Dealing with Problems Compiling MySQL .......................................................... 168
2.9.6 MySQL Configuration and Third-Party Tools ...................................................... 170
2.10 Postinstallation Setup and Testing .............................................................................. 170
2.10.1 Postinstallation Procedures for Unix-like Systems ............................................. 170
2.10.2 Securing the Initial MySQL Accounts ............................................................... 182
2.11 Upgrading or Downgrading MySQL ............................................................................ 186
2.11.1 Upgrading MySQL .......................................................................................... 186
2.11.2 Downgrading MySQL ...................................................................................... 197
2.11.3 Checking Whether Tables or Indexes Must Be Rebuilt ...................................... 199
2.11.4 Rebuilding or Repairing Tables or Indexes ....................................................... 201
2.11.5 Copying MySQL Databases to Another Machine .............................................. 203
2.12 Environment Variables ............................................................................................... 204
2.13 Perl Installation Notes ................................................................................................ 205
2.13.1 Installing Perl on Unix ..................................................................................... 205
2.13.2 Installing ActiveState Perl on Windows ............................................................ 206
2.13.3 Problems Using the Perl DBI/DBD Interface ...................................................... 207
3 Tutorial .................................................................................................................................. 209
3.1 Connecting to and Disconnecting from the Server ......................................................... 209
3.2 Entering Queries ......................................................................................................... 210
3.3 Creating and Using a Database ................................................................................... 213
3.3.1 Creating and Selecting a Database ................................................................... 214
3.3.2 Creating a Table ............................................................................................... 215
3.3.3 Loading Data into a Table ................................................................................. 216
3.3.4 Retrieving Information from a Table ................................................................... 217
3.4 Getting Information About Databases and Tables .......................................................... 230
3.5 Using mysql in Batch Mode ........................................................................................ 231
3.6 Examples of Common Queries .................................................................................... 233
3.6.1 The Maximum Value for a Column .................................................................... 233
3.6.2 The Row Holding the Maximum of a Certain Column .......................................... 233
3.6.3 Maximum of Column per Group ........................................................................ 234
3.6.4 The Rows Holding the Group-wise Maximum of a Certain Column ....................... 234
3.6.5 Using User-Defined Variables ........................................................................... 235
3.6.6 Using Foreign Keys .......................................................................................... 235
3.6.7 Searching on Two Keys .................................................................................... 237
3.6.8 Calculating Visits Per Day ................................................................................. 237
3.6.9 Using AUTO_INCREMENT .................................................................................. 238
3.7 Using MySQL with Apache .......................................................................................... 240
4 MySQL Programs ................................................................................................................... 241
4.1 Overview of MySQL Programs ..................................................................................... 242
4.2 Using MySQL Programs .............................................................................................. 246
4.2.1 Invoking MySQL Programs ............................................................................... 246
4.2.2 Connecting to the MySQL Server ...................................................................... 247
4.2.3 Specifying Program Options .............................................................................. 250