home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeMySQL and mSQLSearch this book

Chapter 3. Installation

Contents:

MySQL
mSQL

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.

3.1. MySQL

Before you begin installing MySQL, you must answer a couple of questions.

  1. Are you going to install MySQL as root or as another user?

    MySQL does not require root access to run, but installing it as root will enable you to make one copy available to everyone on your system. If you do not have root access, you will have to install it in your home directory. However, even if you install MySQL as root, it is a very good idea to run it as a different user. In this way, all data in the database can be protected from all other users by setting the permissions on the data files to only be readable by the special MySQL user. In addition, if the security of the database becomes compromised, the attacker only has access to the special MySQL user account which has no privileges beyond the database.

  2. Are you going to install MySQL from source or from binary?

    There are many precompiled binary packages of MySQL available. Using this method can save time, but limits the amount of customization you can do on your installation. To install from source you need a C compiler and other development tools. If you have these, the benefits gained from installing from source usually outweigh the minor hassles.

WARNING

These two questions are not mutually exclusive. If you install from a binary package you have to install as root. Binary installations will have certain path information hard coded into the binary, forcing you to install as the person who created your pre-built binary. MySQL does supply command line options to override these paths, but usually installing from source is less of a hassle.

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

Asia

Korea

KREONet

http://linux.kreonet.re.kr/mysql/

Japan

Soft Agency

http://www.softagency.co.jp/MySQL/

Nagoya Syouka University

http://mirror.nucba.ac.jp/mirror/mysql/

Nagoya Syouka University

ftp://mirror.nucba.ac.jp/mirror/mysql/

HappySize

http://www.happysize.co.jp/mysql/

HappySize

ftp://ftp.happysize.co.jp/pub/mysql/

Singapore

HJC

http://mysql.hjc.edu.sg/

HJC

ftp://ftp.hjc.edu.sg/mysql/

Taiwan

NCTU

http://mysql.taconet.com.tw/

TTN

http://mysql.ttn.net

Australia

Australia

AARNet/Queensland

http://mirror.aarnet.edu.au/mysql/

AARNet/Queensland

ftp://mirror.aarnet.edu.au/pub/mysql/

Blue Planet/Melbourne

http://mysql.bluep.com

Blue Planet/Melbourne

ftp://mysql.bluep.com/pub/mirror1/mysql/

Tas

http://ftp.tas.gov.au/mysql/

Tas

ftp://ftp.tas.gov.au/pub/mysql/

Africa

South Africa

The Internet Solution/Johannesburg

ftp://ftp.is.co.za/linux/mysql/

Europe

Austria

University of Technology/Vienna

http://gd.tuwien.ac.at/db/mysql/

University of Technology/Vienna

ftp://gd.tuwien.ac.at/db/mysql/

Bulgaria

Naturella

ftp://ftp.ntrl.net/pub/mirror/mysql/

Denmark

Ake

http://mysql.ake.dk

SunSITE

http://sunsite.auc.dk/mysql/

SunSITE

ftp://sunsite.auc.dk/pub/databases/mysql/

Estonia

Tradenet

http://mysql.tradenet.ee

Finland

EUnet

http://mysql.eunet.fi

France

Minet

http://www.minet.net/devel/mysql/

Germany

Bonn University, Bonn

http://www.wipol.uni-bonn.de/MySQL/

Bonn University, Bonn

ftp://ftp.wipol.uni-bonn.de/pub/mirror/MySQL/

Wolfenbuettel

http://www.fh-wolfenbuettel.de/ftp/pub/database/mysql/

Wolfenbuettel

ftp://ftp.fh-wolfenbuettel.de/pub/database/mysql/

Staufen

http://mysql.staufen.de

Greece

NTUA, Athens

http://www.ntua.gr/mysql/

NTUA, Athens

ftp://ftp.ntua.gr/pub/databases/mysql/

Hungary

Xenia

www.mysql.com

Xenia

www.mysql.com

Israel

Netvision

http://mysql.netvision.net.il

Italy

Teta Srl

http://www.teta.it/mysql/

Poland

Sunsite

http://sunsite.icm.edu.pl/mysql/

Sunsite

ftp://sunsite.icm.edu.pl/pub/unix/mysql/

Portugal

lerianet

http://mysql.leirianet.pt

lerianet

ftp://ftp.leirianet.pt/pub/mysql/

Russia

DirectNet

http://mysql.directnet.ru

IZHCOM

http://mysql.udm.net

IZHCOM

http://mysql.udm.net

Romania

Bucharest

http://www.lbi.ro/MySQL/

Bucharest

ftp://ftp.lbi.ro/mirrors/ftp.tcx.se

Timisoara

http://www.dnttm.ro/mysql/

Timisoara

ftp://ftp.dnttm.ro/pub/mysql/

Sweden

Sunet

http://ftp.sunet.se/pub/unix/databases/relational/mysql/

Sunet

ftp://ftp.sunet.se/pub/unix/databases/relational/mysql/

TCX

http://www.tcx.se

TCX

ftp://www.tcx.se

TCX

http://www.mysql.com(Primary Site)

TCX

ftp://ftp.mysql.com(Primary Site)

UK

Omnipotent/UK

http://mysql.omnipotent.net

Omnipotent/UK

ftp://mysql.omnipotent.net

PliG/UK

http://ftp.plig.org/pub/mysql/

PliG/UK

ftp://ftp.plig.org/pub/mysql/

Ukraine

PACO

http://mysql.paco.net.ua

PACO

ftp://mysql.paco.net.ua

North America

Canada

Tryc

http://web.tryc.on.ca/mysql/

USA

Circle Net/North Carolina

http://www.mysql.net

DIGEX

ftp://ftp.digex.net/pub/database/mysql/index.html/

Gina net/Florida

http://www.gina.net/mysql/

Hurricane Electric/San Jose

http://mysql.he.net

Netcasting/West Coast

ftp://ftp.netcasting.net/pub/mysql/

Phoenix

http://phoenix.acs.ttu.edu/mysql/

pingzero/Los Angeles

http://mysql.pingzero.net

South America

Chile

Amerikanclaris

http://www.labs.amerikanclaris.cl/mysql/

vision

http://mysql.vision.cl

Once you have connected to the FTP site, change to the Downloads directory. This directory will list several versions of MySQL like this:

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-aix4.2.1.0-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-aix4.2.1.0-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

Once you have downloaded the MySQL source distribution, unpack the archive using the following:

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:

--without-server

This will compile all of the included MySQL clients, but not the server.

--prefix

This is used to set the installation directory to something other than the default (/usr/local/).

--with-low-memory

This option tells the compiler to not use certain optimizations that use a great deal of memory during the compilation process. Using this option will fix most lack of memory errors encountered during installation.

--localstatedir

This is used to set the directory containing the database data files to something other than the default (/usr/local/var).

--with-charset

This will choose a different character set (default is `latin1'). At the time of this writing, available character sets are big5, danish, cp1251, cp1257, croat, czech, dec8, dos, euc_kr, german1, hebrew, hp8, hungarian, koi8_ru, koi8_ukr, latin1, latin2, swe7, usa7, win1251, win1251u, kr, ujis, sjis, tis620.

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:

./scripts/mysql_install_db

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:

./bin/mysqladmin version

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:

gzip -c mysql-x.xx.xx.tar.gz | tar xvf -
cd mysql-x.xx.xx
./configure
make
make install
./scripts/mysql_install_db
./bin/mysqladmin version

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:

scripts/mysql_install_db

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:

bin/mysqladmin version

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


Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.