The basic commands that you must execute to install a MySQL source
distribution are:
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql var
shell> bin/mysqld_safe --user=mysql &
If you start from a source RPM, do the following:
shell> rpmbuild --rebuild --clean MySQL-VERSION.src.rpm
This makes a binary RPM that you can install. For older versions of
RPM, you may have to replace the command `rpmbuild' with `rpm' instead.
*Note*: This procedure does not set up any passwords for MySQL
accounts.
A more detailed version of the preceding description for installing
MySQL from a source distribution follows:
1. Add a login user and group for `mysqld' to run as:
shell> groupadd mysql
shell> useradd -g mysql mysql
These commands add the `mysql' group and the `mysql' user. The
syntax for `useradd' and `groupadd' may differ slightly on
different versions of Unix, or they may have different names such
as `adduser' and `addgroup'.
You might want to call the user and group something else instead
of `mysql'. If so, substitute the appropriate name in the
following steps.
2. Perform the following steps as the `mysql' user, except as noted.
3. Pick the directory under which you want to unpack the distribution
and change location into it.
4. Obtain a distribution file using the instructions in *Note
getting-mysql::.
5. Unpack the distribution into the current directory:
shell> gunzip < /PATH/TO/MYSQL-VERSION.tar.gz | tar xvf -
This command creates a directory named `mysql-VERSION'.
With GNU `tar', no separate invocation of `gunzip' is necessary.
You can use the following alternative command to uncompress and
extract the distribution:
shell> tar zxvf /PATH/TO/MYSQL-VERSION-OS.tar.gz
6. Change location into the top-level directory of the unpacked
distribution:
shell> cd mysql-VERSION
Note that currently you must configure and build MySQL from this
top-level directory. You cannot build it in a different directory.
7. Configure the release and compile everything:
shell> ./configure --prefix=/usr/local/mysql
shell> make
When you run `configure', you might want to specify other options.
Run `./configure --help' for a list of 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
`config.log' that you think can help solve the problem. Also
include the last couple of lines of output from `configure'.
8. Install the distribution:
shell> make install
You might need to run this command as `root'.
If you want to set up an option file, use one of those present in
the `support-files' directory as a template. For example:
shell> cp support-files/my-medium.cnf /etc/my.cnf
You might need to run this command as `root'.
If you want to configure support for `InnoDB' tables, you should
edit the `/etc/my.cnf' file, remove the `#' character before the
option lines that start with `innodb_...', and modify the option
values to be what you want.
9. Change location into the installation directory:
shell> cd /usr/local/mysql
10. If you ran the `make install' command as `root', the installed
files will be owned by `root'. Ensure that the installation is
accessible to `mysql' by executing the following commands as
`root' in the installation directory:
shell> chown -R mysql .
shell> chgrp -R mysql .
The first command changes the owner attribute of the files to the
`mysql' user. The second changes the group attribute to the
`mysql' group.
11. If you have not installed MySQL before, you must create the MySQL
data directory and initialize the grant tables:
shell> bin/mysql_install_db --user=mysql
If you run the command as `root', include the `--user' option as
shown. If you run the command while logged in as `mysql', you can
omit the `--user' option.
The command should create the data directory and its contents with
`mysql' as the owner.
After using `mysql_install_db' to create the grant tables for
MySQL, you must restart the server manually. The `mysqld_safe'
command to do this is shown in a later step.
12. Most of the MySQL installation can be owned by `root' if you like.
The exception is that the data directory must be owned by `mysql'.
To accomplish this, run the following commands as `root' in the
installation directory:
shell> chown -R root .
shell> chown -R mysql var
13. If you want MySQL to start automatically when you boot your
machine, you can copy `support-files/mysql.server' to the location
where your system has its startup files. More information can be
found in the `support-files/mysql.server' script itself.
14. You can set up new accounts using the `bin/mysql_setpermission'
script if you install the `DBI' and `DBD::mysql' Perl modules.
After everything has been installed, you should test your distribution.
To start the MySQL server, use the following command:
shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &
If you run the command as `root', you should use the `--user' option as
shown. The value of the option is the name of the login account that
you created in the first step to use for running the server. If you run
the command while logged in as that user, you can omit the `--user'
option.
If the command fails immediately and prints `mysqld ended', you can
find some information in the `HOST_NAME.err' file in the data directory.
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.