To install MySQL from source, first configure, build, and install from a source package. Then follow the same postinstallation setup sequence as for a binary installation.
If you start from a source RPM, use the following command to make a binary RPM that you can install. If you do not have rpmbuild, use rpm instead.
rpmbuild --rebuild --clean MySQL-
The result is one or more binary RPM packages that you install as indicated in Section 2.5.1, “Installing MySQL on Linux Using RPM Packages”.
The sequence for installation from a compressed
tar file source distribution is similar to the
process for installing from a generic binary distribution that is
detailed in Section 2.2, “Installing MySQL on Unix/Linux Using Generic Binaries”. For a MySQL
.tar.gz source distribution, the basic
installation command sequence looks like this:
# Preconfiguration setup shell>
useradd -g mysql mysql# Beginning of source-build specific instructions shell>
tar zxvf mysql-shell>
make install# End of source-build specific instructions # Postinstallation setup shell>
chown -R mysql .shell>
chgrp -R mysql .shell>
chown -R root .shell>
chown -R mysql var# Next command is optional shell>
cp support-files/my-medium.cnf /etc/my.cnfshell>
bin/mysqld_safe --user=mysql &# Next command is optional shell>
cp support-files/mysql.server /etc/init.d/mysql.server
A more detailed version of the source-build specific instructions
is shown following. Perform the following steps as the
mysql user, except as noted.
The procedure shown here does not set up any passwords for MySQL accounts. After following the procedure, proceed to Section 2.12, “Postinstallation Setup and Testing”, for postinstallation setup and testing.
Set up the
mysql user and group that will
be used to run and execute the MySQL server and own the
database directory. For details, see
mysql System User and Group, in
Section 2.2, “Installing MySQL on Unix/Linux Using Generic Binaries”.
Pick the directory under which you want to unpack the distribution and change location into it.
Obtain a distribution file using the instructions in Section 2.1.3, “How to Get MySQL”.
Unpack the distribution into the current directory.
tar can uncompress and unpack the
distribution if it has
z option support:
This command creates a directory named
If your tar does not have
z option support, use
gunzip to unpack the distribution and
tar to unpack it:
/path/to/mysql-VERSION.tar.gz | tar xvf -
Change location into the top-level directory of the unpacked distribution:
Configure the source directory:
When you run configure, you might want to
specify other options. For example, if you need to debug
mysqld or a MySQL client, run
configure with the
--with-debug option, and
then recompile and link your clients with the new client
library. See Section 22.4, “Debugging and Porting MySQL”.
Run ./configure --help for a list of options. Section 2.11.4, “MySQL Source-Configuration Options”, discusses some of the more useful options.
If configure fails and you are going to
send mail to a MySQL mailing list to ask for assistance,
please include any lines from
that you think can help solve the problem. Also include the
last couple of lines of output from
configure. To file a bug report, please use
the instructions in Section 1.7, “How to Report Bugs or Problems”.
Compile the source distribution:
Use gmake instead on systems where you are using GNU make and it has been installed as gmake.
If the compile fails, see Section 2.11.5, “Dealing with Problems Compiling MySQL”, for help.
Install the distribution:
You might need to run this command as
The remainder of the installation process, including setting up the configuration file, creating the core databases, and starting the MySQL server, are identical to the remainder of the process as shown in Generic Binary Install.
After everything has been installed, test the distribution. To start the MySQL server, use the following command:
/usr/local/mysql/bin/mysqld_safe --user=mysql &
If you run the command as
root, you should use
--user option as shown. The option value is
the name of the login account that you created in the first step
to use for running the server. If you run the
mysqld_safe command while logged in as that
user, you can omit the
If the command fails immediately and prints
ended, look for information in the error log (which by
default is the
in the data directory).
For more information about mysqld_safe, see Section 4.3.2, “mysqld_safe — MySQL Server Startup Script”.
To make it more convenient to invoke programs installed in
/usr/local/mysql/bin, you can add that
directory to your
PATH environment variable
setting. That enables you to run a program by typing only its
name, not its entire path name. See
Section 4.2.10, “Setting Environment Variables”.
The accounts that are listed in the MySQL grant tables initially have no passwords. After starting the server, you should set up passwords for them using the instructions in Section 2.12, “Postinstallation Setup and Testing”.