Chapter 3. Installation
Like most services, the MySQL and mSQL databases run as background processes (also called daemons on Unix systems). This chapter gives an overview on how to unpack and build them.
The first step in installing MySQL, either from source or binary, is to obtain the distribution. Table 3-1 lists sites that contain copies of the MySQL source code and binaries.
Table 3-1. Sites that Contain Copies of MySQL Source Code and Binaries
MySQL-3.21 MySQL-3.22 MySQL-3.23
The highest version number is an unstable release where new features are being added and tested. Individual subversions of this stage will always be labeled `alpha', `beta', or `gamma'. The previous version is the current stable version. This version has been thoroughly tested and is believed to be bug free. Earlier versions are also available for archive purposes.
If the development version is still in `alpha' stage, you should definitely stick with the stable version unless you like living on the edge. Likewise, if the development version is in `beta' stage, it's probably a good idea to use the stable version unless the new version has features that you really need, or if the system you are running it on is not absolutely critical. On the other hand, if the development version is at `gamma', you should feel confident in using it, unless there is a known problem affecting your system.
You can see exactly what stage a particular version of MySQL is at by changing to the directory for that version. For example, the directory MySQL-3.22 may look something like this:
mysql-3.22.19-beta-sgi-irix6,4-mip.tgz mysql-3.22.21a-beta-ibm-aix126.96.36.199-rs6000.tgz mysql-3.22.31-pc-linux-gnu-i586.tgz mysql-3.22.33-sun-solaris2.6-sparc.tgz mysql-3.22.33.tar.gz
The files with specific machine and operating system names are binary versions for that system. Files without a specific machine, such as the last file listed are the source code. If there is no stage label (`alpha', `beta', `gamma') attached to a file, it is a stable version. This is a case for the last two files in the list: One is a binary version for Sun Solaris 2.6 on Sparc hardware and the other is the source code. The other, older, versions exist because the development team does not always have the time and resources to compile every subversion of MySQL on every operating system and hardware configuration in existence. In fact, most of the pre-compiled versions are submitted by regular users who have had success compiling the latest version on their system.
With this information in mind, you should now choose the version of MySQL you wish to use and download the source distribution if you are going to compile MySQL, or the correct binary distribution for you machine, if it exists. If a binary distribution does not exist for your exact configuration, first check to see if one exists for a slightly different version of your system. For instance, mysql-3.22.32a-ibm-aix188.8.131.52-powerpc.tgz may also run for Version 4.1.4 of AIX on the same type of hardware. If you cannot find a working version this way, see if versions for your configuration exist for older versions of MySQL. If not, you will have to compile from source. If this is the case for you and you successfully compile and run MySQL, you should consider submitting a copy of your compiled binaries to the MySQL team for inclusion in the archive.
3.1.1. Installing from Source
gunzip -c mysql-x.xx.xx.tar.gz | tar xvf -
Where mysql-x.xx.xx.tar.gz is the name of the file you downloaded. This will create a directory named mysql-x.xx.xx within the current directory. Change to this directory.
Run the configure script in the current directory. Invoke the script as ./configure so that you do not accidentally run a program with the same name elsewhere on your system. Many installations will configure fine without any options, but for those that do not, configure provides a wide array. Running with the --help switch will list them all, but the following are the most common:
After the configure script has completed, run make in the current directory. This will compile everything.
Once everything is finished compiling, make install will install everything into its proper place.
If this is the first time you are installing MySQL on this machine, or if all of the MySQL database files have been deleted since the last install, run the following to create the database structure and the administrative tables:
This will also start the server daemon. To make sure it is running, change to the installation directory (/usr/local/ by default) and run the following:
The output should look something like this:
mysqladmin Ver 7.11 Distrib 3.22.23b, for linux on i586 TCX Datakonsult AB, by Monty Server version 3.22.23b-debug Protocol version 10 Connection Localhost via UNIX socket UNIX socket /tmp/mysql.sock Uptime: 6 sec Threads: 1 Questions: 1 Slow queries: 0 Opens: 6 Flush tables: 1 Open tables: 2 Memory in use: 1093K Max memory used: 1093K
To summarize, a sequence of installation steps looks like this:
3.1.2. Installing a Binary Distribution
Once you have downloaded the binary distribution you must pick a directory to contain the MySQL files. The most common location is /usr/local/mysql, but where you put your distribution largely depends on the needs of your users and the access rights you have to the machine.
Change to the directory just above the one you wish to house the MySQL distribution. For example, if you wish to use /usr/local/mysql, change to /usr/local now. Run the following to unpack the distribution:
gunzip -c /tmp/mysql-x.xx.xx-mymachine.tgz | tar xvf -
Here /tmp is the directory where you downloaded MySQL and mysql-x.xx.xx-mymachine.tgz is the name of the file you downloaded.
This should create a directory called mysql-x.xx.xx within the current directory. If you want the files to be in a directory called just mysql, create a link:
ln -s mysql-x.xx.xx mysql
Next, check to see if the binary package contains the access grant tables. Change to the directory mysql/mysql from the current directory. If this directory does not exist or is empty, you must create the tables yourself. Change back one directory to the main mysql installation directory and run the following:
The previous command has to be run only once. To actually start the MySQL daemon, enter:
bin/safe_mysqld --log &
To see if the daemon is running properly, run the following:
The output should look something like this:
Mysqladmin Ver 6.3 Distrib 3.21.33, for sun-solaris2.6 on sparc TCX Datakonsult AB, by Monty Server version 3.21.17-alpha Protocol version 10 Connection Localhost via UNIX socket TCP Port 3333 UNIX socket /tmp/mysql.sock Uptime: 13 sec Running threads: 1 Questions: 20 Reloads: 2 Open Tables: 3
Copyright © 2001 O'Reilly & Associates. All rights reserved.