HomeMySQL Page 5 - MySQL Installation and Configuration
Installing MySQL from a Source Distribution (Linux/Unix) - MySQL
In this chapter, Vikram discusses how to obtain, install, configure, and test the MySQL server on Unix and Windows. It also explains the differences between the different MySQL sever versions available, with a view to helping you select the right one for your needs. This excerpt comes from chapter three of MySQL: The Complete Reference, by Vikram Vaswani (McGraw-Hill/Osborne, ISBN 0-07-222477-0, 2004).
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 5.
FIGURE 5The directory structure obtained on unpackaging of a MySQL source tarball 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 6 has a sample) as configure configures and sets up the variables needed for the compilation process.
FIGURE 6Configuring the MySQL source tree on Linux
5. Now compile the program using make:
Watch as your screen fills up with all manner of strange symbols and characters (see Figure 7).
FIGURE 7Building MySQL on Linux
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.
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 8 demonstrates what your screen should look like during the installation process.
FIGURE 8Installing compiled 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:
MySQL should start up normally, reading the base tables created in /usr/local/mysql/var.
At this point, you can proceed to the section titled “Testing MySQL” to verify that everything is working as it should.
In case you’re wondering, all the binaries used when developing this book have been built on Linux using the following software versions:
Remember: this is chapter three of MySQL: The Complete Reference, by Vikram Vaswani (McGraw-Hill/Osborne, ISBN 0-07-222477-0, 2004). Vikram is the founder of Melonfire, and has had numerous articles featured on Dev Shed. Buy this book now.