Home arrow MySQL arrow 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).

  1. MySQL Installation and Configuration
  2. Choosing Between Binary and Source Distributions
  3. Installing and Configuring MySQL (Linux/Unix)
  4. Installing MySQL from a Binary Tarball Distribution (Linux/Unix)
  5. Installing MySQL from a Source Distribution (Linux/Unix)
  6. Installing and Configuring MySQL on Windows
  7. Installing MySQL from a Source Distribution (Windows)
  8. Testing MySQL
  9. Post-Installation Steps
By: McGraw-Hill/Osborne
Rating: starstarstarstarstar / 134
April 28, 2004

print this article



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.

MySQL Installation and Configuration
FIGURE 5  The 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.)

[root@host]# ./configure --prefix=/usr/local/mysql

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.

MySQL Installation and Configuration
FIGURE 6  Configuring the MySQL source tree on Linux

5. Now compile the program using make:

[root@host]# make

Watch as your screen fills up with all manner of strange symbols and characters (see Figure 7).

MySQL Installation and Configuration
FIGURE 7  Building 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:

System Configuration Time Taken to Compile MySQL
Pentium-II@350 MhZ, 64 MB RAM 45 minutes
Pentium-III@700MhZ, 256 MB RAM 30 minutes
AMD Athlon MP 1500+, SuSE Linux 7.3 8 minutes
AMD Opteron@2x1.6 GHz, UnitedLinux 1.0 7 minutes
Apple PowerMac G4@2x1.2 GHz, Mac OS X 10.2.4 14 minutes
Compaq AlphaServer DS20@500 MHz, SuSe Linux 7.0 17 minutes
HP 9000/800/A500-7X, HP-UX 11.11 14 minutes
IBM RS/6000, AIX 4.3.3 35 minutes
Intel Itanium2@900 MHz, Red Hat AS 2.1 14 minutes
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.

MySQL Installation and Configuration
FIGURE 8  Installing 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:

[root@host]# /usr/local/mysql/scripts/mysql_install_db

10. Alter the ownership of the MySQL binaries so that they are owned by root:

[root@host]# chown -R root /usr/local/mysql

Now ensure that the newly minted mysql user has read/write access to the MySQL data directories:

[root@host]# chown -R mysql /usr/local/mysql/var
[root@host]# chgrp -R mysql /usr/local/mysql

11. Start the MySQL server by manually running the mysqld daemon:

[root@host]# /usr/local/mysql/bin/mysqld_safe –-user=mysql &

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.

Version Control

In case you’re wondering, all the binaries used when developing this book have been built on Linux using the following software versions:

  • mysqld 4.0.15-standard
  • mysqld-4.1-alpha
  • rpm 4.1
  • gcc 3.2
  • tar 1.13.25
  • gunzip 1.3.3
  • unzip 5.50
  • make 3.79.1
  • autoconf 2.53
  • automake 1.6.3

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.

>>> More MySQL Articles          >>> More By McGraw-Hill/Osborne

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Oracle Unveils MySQL 5.6
- MySQL Vulnerabilities Threaten Databases
- MySQL Cloud Options Expand with Google Cloud...
- MySQL 5.6 Prepped to Handle Demanding Web Use
- ScaleBase Service Virtualizes MySQL Databases
- Oracle Unveils MySQL Conversion Tools
- Akiban Opens Database Software for MySQL Use...
- Oracle Fixes MySQL Bug
- MySQL Databases Vulnerable to Password Hack
- MySQL: Overview of the ALTER TABLE Statement
- MySQL: How to Use the GRANT Statement
- MySQL: Creating, Listing, and Removing Datab...
- MySQL: Create, Show, and Describe Database T...
- MySQL Data and Table Types
- McAfee Releases Audit Plugin for MySQL Users

Developer Shed Affiliates


Dev Shed Tutorial Topics: