The basic commands that you must execute to install a MySQL source distribution are:
shell>groupadd mysqlshell>useradd -g mysql mysqlshell>gunzip < mysql-shell>VERSION.tar.gz | tar -xvf -cd mysql-shell>VERSION./configure --prefix=/usr/local/mysqlshell>makeshell>make installshell>cp support-files/my-medium.cnf /etc/my.cnfshell>cd /usr/local/mysqlshell>chown -R mysql .shell>chgrp -R mysql .shell>bin/mysql_install_db --user=mysqlshell>chown -R root .shell>chown -R mysql varshell>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.
This procedure does not set up any passwords for MySQL accounts. After following the procedure, proceed to Section 2.11, “Post-Installation Setup and Testing”, for post-installation setup and testing.
A more detailed version of the preceding description for installing MySQL from a source distribution follows:
Add a login user and group for mysqld to run as:
shell>groupadd mysqlshell>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.
          
            Perform the following steps as the mysql
            user, except as noted.
          
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:
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
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.
Configure the release and compile everything:
shell>./configure --prefix=/usr/local/mysqlshell>make
When you run configure, you might want to specify other options. Run ./configure --help for a list of options. Section 2.10.2, “Typical configure 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
            config.log 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.6, “How to Report Bugs or Problems”.
          
If the compile fails, see Section 2.10.4, “Dealing with Problems Compiling MySQL”, for help.
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. See
            Section 4.2.3.3, “Using Option Files”, and
            Section 13.6.2, “InnoDB Configuration”.
          
Change location into the installation directory:
shell> cd /usr/local/mysql
            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.
          
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.
            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
            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; see also Section 2.11.2.2, “Starting and Stopping MySQL Automatically”.
          
            
            
            
            You can set up new accounts using the
            bin/mysql_setpermission script if you
            install the DBI and
            DBD::mysql Perl modules. See
            Section 4.6.14, “mysql_setpermission — Interactively Set Permissions in Grant
Tables”. For Perl module
            installation instructions, see
            Section 2.15, “Perl Installation Notes”.
          
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
More information about mysqld_safe is given in Section 4.3.2, “mysqld_safe — MySQL Server Startup Script”.
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.11, “Post-Installation Setup and Testing”.


User Comments
If you forget to do --prefix=/usr/local/mysql
during configure, your distribution will install
into /usr/local. Rerunning configure with the --
prefix=/usr/local/mysql seemed to make the
installation go into /usr/local/mysql, but the
script "mysql_install_db", etc...seemed to
require the --basedir argument, and SQL wouldn't
start. So if you forget to do --
prefix=/usr/local/mysql, clear out all configure
logs/caches before rerunning ./configure.
Before following Mr. Juszczak's suggestion above I suggest that you do the following...
If you realize that you did not add the --prefix argument, then you may simply continue without changing anything. /usr/local is a perfectly acceptable place to install mysql. If you would rather do things *exactly* by the book, then before you go back and reconfigure as he suggests, do the following (make sure you are in the mysql src directory and logged in as root (or using sudo) first):
<pre>
make uninstall
make distclean
</pre>
The command uninstall directive tells make to go and remove all the files and directories created with the install directive. This will (hopefully) clean up mysql from /usr/local.
The distclean directive tells make to not only delete all the compiled files but to also remove any config.cache, config.log or config.status information. Basically return the sourcetree to it's state just after untaring it.
Good, luck, have fun, and when all else fails stop by #linuxhelp on your favorite IRC network (I recommend EFnet and Undernet).
> If you realize that you did not add the --prefix argument,
> then you may simply continue without changing anything.
> /usr/local is a perfectly acceptable place to install mysql.
Having just tried this route, I think that Mr. Juszczak is right: if you use the default configure options, there is little hope for getting a working install. The permissions will bite you again and again. See Bug #2029 for more info.
With most editions of Linux and the BSDs, it is often better to use /usr or /usr/local as the prefix. That way the executables (such as mysql and mysqladmin) will be placed in /usr/bin or /usr/local/bin and will be in pre-existing paths for the users, so the command line tools are easily used.
Without doing that, you have to edit profile files or put in links to the executables, or use full paths because they will not be in the paths normally checked.
Just my $0.02 worth.
GP
On RedHat9, I HAD to do the second part of step 7
shell> cp support-files/my-medium.cnf /etc/my.cnf
I recomplied and installed about 6 times, mysqld would not start until I copied the option file. After that, it worked beautifully. So much for optional ;>
When running make, if you get errors about automake-1.7 not being installed when you have automake 1.8 installed, try these commands as root:
cd /usr/bin
ln -s automake automake-1.7
When I was installing on SuSE, I added the mysql group and user as per the example. However, this added the mysql user to the SuSE login screen. Furthermore, in YaST, it listed it under the local groups and users. To fix this, I instead created the group and user as a system user/group (warning: a neophyte's method follows):
groupadd -r mysql
useradd -r -g mysql mysql
When you try to run
bin/mysqld_safe --user=mysql
If you get an error in your var/<host_name>.err file similar to:
Can't create/write to file 'tmp/ib0X0Utw' (Errcode: 13)
InnoDB: Error: unable to create temporary file; errorno: 13
[ERROR] Can't start server : Bind on unix socket: Permission denied
Try chmod /tmp files to 777:
chmod -R 777 /tmp
If you get a message saying "termcap/curses" is missing you need to download and make ncurses (at gnu.org).
bin/mysql_install_db --user=mysql
assumes that you want to use the configuration in /etc/my.cnf
If you want to use another one (for instance, if you're not root and cannot change that file) then
bin/mysql_install_db --defaults-file=your-conf-file
I had an old /etc/mysql/my.cnf, left over from some long-gone installation. Was causing problems running bin/mysql_install_db. Removing and sym linking to /etc/my.cnf resolved.
Geronimo
Add your own comment.