HomeMySQL Page 4 - MySQL Configuration and Installation
Installing MySQL on UNIX from a Source Distribution - MySQL
If you ever wanted to start using the open source MySQL server application on your computer, this article is for you. It will show you how to obtain, install, configure, and test the MySQL server on your system, whether you are running UNIX or Windows. It is excerpted from My SQL The Complete Reference by Vikram Vaswani (McGraw-Hill/Osborne, 2003; ISBN: 0072224770).
If you’re planning to install MySQL from a source distribution, you’ll need to untar the source tree and go through the traditional configure-make-make install cycle to get MySQL up and running. This is a fairly time-consuming and complex process, and it’s one that shouldn’t really be attempted by novice users; however, if you’re determined to do it, here’s how:
1. Ensure that you’re logged in as root:
[user@host]# su - root
2. Switch to the directory containing the source tarball, and extract the files within it. (Note that you will need approximately 80 MB of free space for the source tree.)
[root@host]# cd /tmp [root@host]# tar -xzvf mysql-4.0.9-gamma.tar.gz
Remember to replace the file name in italics with the file name of your source tarball.
3. Move into the directory containing the source code,
[root@host]# cd mysql-4.0.9-gamma
and take a look at the contents with ls:
[root@host]# ls -l
You should see something like Figure 3-5.
Figure 3-5.The directory structure obtained on unpackaging of a MySQL source tarball on Linux
Figure 3-6.Configuring the MySQL source tree on Linux
Take a look at the sidebar entitled “Up a Tree” for more information on what each directory contains.
4. Now, set variables for the compile process via the included configure script. (Note the use of the --prefix argument to configure, which sets the default installation path for the compiled binaries.)
You should see a few screens of output (Figure 3-6 has a sample) as configure configures and sets up the variables needed for the compilation process.
5. Now compile the program using make:
Watch as your screen fills up with all manner of strange symbols and characters (see Figure 3-7).
The compilation process takes a fair amount of time (refer to the sidebar titled “Watching the Clock” for my empirical observations on how long you’ll be waiting), so this is a good time to get yourself a cup of coffee or check your mail.
Now that you’re all done, you can test to ensure that everything is working properly.
6. Run the following command:
[root@host]# make tests
Handcrafting Your Build You can pass configure a number of command-line options that affect the build process. Here’s a list of the more interesting ones:
• --prefix Sets the prefix for installation paths • --without-server Disables compilation of the server, and compiles only the MySQL client programs and libraries • --localstatedir Sets the location in which the MySQL databases will be stored • --with-charset Sets a default character set • --with-debug Turns on extended debugging • --with-raid Enables RAID support • --with-embedded-server Builds the libmysqld embedded server library • --without-query-cache Disables the query cache • --without-debug Disables debugging routines • --with-openssl Includes OpenSSL support Use the configure --help command to get a complete list of options.
Figure 3-7.Building MySQL on Linux
Watching the Clock Compiling MySQL is a fairly time-consuming process, and you should be prepared to spend anywhere between 15 to 60 minutes on the task. The following table contains some empirical observations on the time taken to compile the program on various hardware configurations:
Time Taken to Compile MySQL
Pentium-II@350 MhZ, 64 MB RAM
Pentium-III@700MhZ, 256 MB RAM
AMD Athlon MP 1500+, SuSE Linux 7.3
AMD Opteron@2x1.6 GHz, UnitedLinux 1.0
Apple PowerMac G4@2x1.2 GHz, Mac OS X 10.2.4
Compaq AlphaServer DS20@500 MHz, SuSe Linux 7.0
HP 9000/800/A500-7X, HP-UX 11.11
IBM RS/6000, AIX 4.3.3
Intel Itanium2@900 MHz, Red Hat AS 2.1
MIPS R5000@500 MHz, SGI IRIX 6.5
2 hours 30 minutes
7. Install the MySQL binaries to their new home in /usr/local/mysql:
[root@host]# make install
Figure 3-8 demonstrates what your screen should look like during the installation process.
Figure 3-8.Installing complied MySQL binaries on Linux
8. Create the special mysql user and group with the groupadd and useradd commands:
[root@host]# groupadd mysql [root@host]# useradd -g mysql mysql
9. Run the initialization script, mysql_install_db, which ships with the program, to prepare MySQL for operation: