Follow these steps to install MySQL on a Linux/UNIX server. You must be logged in as the root user to install MySQL.
RPM Installation for Linux
If you are using a Linux system that supports RPM packages, such as Red Hat, SUSE, or Fedora, this is the easiest installation method to use. You simply download the appropriate packages and install them using the rpm utility.
The RPM distribution is split into the following packages. The filename prefix for each package is shown in parentheses.
The full filename of a package consists of the prefix shown in this list, the MySQL version number, and the platform it is compiled for.
For example, the latest version of the MySQL Server package for an Intel-based Linux system is installed from an RPM package named MySQL-server-5.0.18-0.i386.rpm.
Use the rpm command with the i switch to install the RPM packages. If you have downloaded several packages, you can install them together by using the following command:
$ rpm i MySQL*.rpm
RPM installation creates a service for MySQL. You can start the MySQL server by issuing the following command:
# /sbin/service mysql start
If you are unable to use RPM, you will still likely find a precompiled binary version of MySQL available for your system.
The binary distribution of MySQL is a single compressed archive that contains the server, client programs, and development libraries. It is downloadable in a .tar.gz filearchived using tar and compressed using gzip. Three versions of each binary distribution exist: Standard, Max, and Debug.
The binary download filename consists of mysql-standard (or mysql-max, for Max) followed by the version number and the platform. For example, if you are installing MySQL on an Intel-based OpenBSD system, the package you require will be named mysql-standard-5.0.16-openbsd3.7-i386.
After downloading the appropriate file, extract it using the following command. Use the cd command to navigate to the location where you want to install the files first: /usr/mysql and /usr/local/mysql are typical locations.
$ tar zxvf mysql-standard-5.0.16-openbsd3.7-i.386.tar.gz
To start the MySQL server, run the mysqld_safe program, which will have been installed to the bin directory. You should run this program in the background as follows:
# /usr/local/mysql/bin/mysqld_safe &
Installing from Source
MySQL is open source, so you are free to download the complete source code, if you want. This section deals with installing MySQL from source code.
The source code downloads appear at the very bottom of the downloads page. They are available as a .tar.gz file; the filename simply contains the version number.
Begin by extracting the latest version of the MySQL source to a suitable location, such as /usr/local/src.
# tar zxvf mysql-5.0.18.tar.gz
Next, run the configure program to allow the MySQL installation process to gather information about your system.
The configure program generates a Makefile, so now you can run the make command to compile the MySQL server and client programs and the development libraries.
Compiling MySQL might take some time, but when it is complete, you can install the various components to their correct locations by issuing a make install command.