Search the MySQL manual:

2.2.11 Installing a MySQL Binary Distribution

This chapter covers the installation of MySQL binary distributions (.tar.gz Archives) for various platforms (see section 2.2.10 MySQL Binaries Compiled by MySQL AB for a detailed list).

In addition to these generic packages, we also offer binaries in platform-specific package formats for selected platforms. See section 2.1 Quick Standard Installation of MySQL for more information on how to install these.

The generic MySQL binary distributions are packaged as gzip-compressed GNU tar archives (.tar.gz). You need the following tools to install a MySQL binary distribution:

If you run into problems, please always use mysqlbug when posting questions to mysql@lists.mysql.com. Even if the problem isn't a bug, mysqlbug gathers system information that will help others solve your problem. By not using mysqlbug, you lessen the likelihood of getting a solution to your problem. You will find mysqlbug in the `bin' directory after you unpack the distribution. See section 1.7.1.3 How to Report Bugs or Problems.

The basic commands you must execute to install and use a MySQL binary distribution are:

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db
shell> chown -R root  .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &
or
shell> bin/mysqld_safe --user=mysql &
if you are running MySQL 4.x

You can add new users using the bin/mysql_setpermission script if you install the DBI and DBD-mysql Perl modules.

A more detailed description follows.

To install a binary distribution, follow these steps, then proceed to section 2.4 Post-installation Setup and Testing, for post-installation setup and testing:

  1. Pick the directory under which you want to unpack the distribution, and move into it. In the following example, we unpack the distribution under `/usr/local' and create a directory `/usr/local/mysql' into which MySQL is installed. (The following instructions, therefore, assume you have permission to create files in `/usr/local'. If that directory is protected, you will need to perform the installation as root.)
  2. Obtain a distribution file from one of the sites listed in section 2.2.1 How to Get MySQL. MySQL binary distributions are provided as compressed tar archives and have names like `mysql-VERSION-OS.tar.gz', where VERSION is a number (for example, 3.21.15), and OS indicates the type of operating system for which the distribution is intended (for example, pc-linux-gnu-i586). Note that all binaries are built from the same MySQL source distribution.
  3. Add a 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. They may also be called adduser and addgroup. You may wish to call the user and group something else instead of mysql.
  4. Change into the intended installation directory:
    shell> cd /usr/local
    
  5. Unpack the distribution and create the installation directory:
    shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
    shell> ln -s full-path-to-mysql-VERSION-OS mysql
    
    Using GNU tar, you can also replace the first line with the following alternative command to decompress and extract the distribution in one go:
    shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
    
    The first command creates a directory named `mysql-VERSION-OS'. The second command makes a symbolic link to that directory. This lets you refer more easily to the installation directory as `/usr/local/mysql'.
  6. Change into the installation directory:
    shell> cd mysql
    
    You will find several files and subdirectories in the mysql directory. The most important for installation purposes are the `bin' and `scripts' subdirectories.
    `bin'
    This directory contains client programs and the server You should add the full pathname of this directory to your PATH environment variable so that your shell finds the MySQL programs properly. See section F Environment Variables.
    `scripts'
    This directory contains the mysql_install_db script used to initialise the mysql database containing the grant tables that store the server access permissions.
  7. If you would like to use mysqlaccess and have the MySQL distribution in some non-standard place, you must change the location where mysqlaccess expects to find the mysql client. Edit the `bin/mysqlaccess' script at approximately line 18. Search for a line that looks like this:
    $MYSQL     = '/usr/local/bin/mysql';    # path to mysql executable
    
    Change the path to reflect the location where mysql actually is stored on your system. If you do not do this, you will get a Broken pipe error when you run mysqlaccess.
  8. Create the MySQL grant tables (necessary only if you haven't installed MySQL before):
    shell> scripts/mysql_install_db
    
    Note that MySQL versions older than Version 3.22.10 started the MySQL server when you run mysql_install_db. This is no longer true.
  9. Change ownership of binaries to root and ownership of the data directory to the user that you will run mysqld as:
    shell> chown -R root  /usr/local/mysql/.
    shell> chown -R mysql /usr/local/mysql/data
    shell> chgrp -R mysql /usr/local/mysql/.
    
    The first command changes the owner attribute of the files to the root user, the second one changes the owner attribute of the data directory to the mysql user, and the third one changes the group attribute to the mysql group.
  10. If you want to install support for the Perl DBI/DBD interface, see section 2.7 Perl Installation Comments.
  11. If you would like 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 and in section 2.4.3 Starting and Stopping MySQL Automatically.

After everything has been unpacked and installed, you should initialise and test your distribution.

You can start the MySQL server with the following command:

shell> bin/mysqld_safe --user=mysql &

Now proceed to section 4.7.2 mysqld_safe, The Wrapper Around mysqld, and See section 2.4 Post-installation Setup and Testing.

User Comments

Posted by Lawrence Sheed on Tuesday January 29 2002, @8:30am[Delete] [Edit]

RPM's complaining about Perl5 not being there, when it actually is?

Just use --nodeps. it's looking for /usr/bin/perl5 in the rpm database, not in your filesystem. if you don't use rpms for perl (or maybe even if you do in some circumstances), then that won't be in there. i think the -bench rpm always required perl, but the others didn't. do they all now? nevertheless, rpm -ivh --nodeps MySQL*rpm
or whatever. should be fine as long as /usr/bin/perl and /usr/bin/perl5 exist in the filesystem, regardless of the rpm db.

From http://lists.omnipotent.net/mysql/

Posted by Joe B on Tuesday January 29 2002, @8:30am[Delete] [Edit]

I just built perl5.6 on my Redhat 6.2 laptop. I tried installing the 3.23.28 gamma version of the MySQL server & it complained that I needed perl5. Uh, guys I've got 5.6 here. So before I started thinking that I was doing something wrong, I figured that I'd search the documentation.

I didn't find anything official, but I just wnat to say thank you to the guy who posted the rpm --nodeps tip. It worked!! And you've saved me from an evening of frustration.

Peace
Joey B.
New York City

Posted by targosd on Tuesday January 29 2002, @8:30am[Delete] [Edit]

When installing the binary
distribution from
www.sunfreeware.com on Sparc/SOLARIS 8 the
following line needs changed from above.
change shell> chown -R mysql /usr/local/mysql/data
to shell> chown -R mysql /usr/local/mysql/var

Posted by Robert Wallette on Friday June 14 2002, @9:01pm[Delete] [Edit]

Like one of the commentors above mentioned, I had
a problem with mysql shutting down after start.
I did a little digging, and inside the data
directory (mysql/data/) found a file named
Tank.err (Tank is my server name). Inside this
file are logs of errors that occurred. In my
case, mysql claimed that it was unable to change
to user mysql to start the mysqld daemon.
Issuing a "su mysql" command before
trying "./bin/safe_mysqld --user=mysql" seemed to
provide a work-around. I don't know why mysql
was unable to change to the mysql user (any
ideas, anyone?), but at least this allowed me to
start the server.

Posted by Justin Palamar on Friday September 6 2002, @7:28am[Delete] [Edit]

I had the same problem during my Red Hat Linux 7.2
installation and MySQL 3.23.34.

In any case after confering with the log file for mysql
(var/log/mysql I believe) I found it was unable to
access the files (permission tables, etc) created by
the mysql_install_db script.

The solution is to go the home directory where the
you installed tables are at that mysqld or
safe_mysqld is TRYING to access (check that log file,
mine were located in /var/lib and /var/lib/mysql) and
make sure that they are 'owned' by "mysql" I
installed as "root" and they were owned my "root"
by default, once I did "chown mysql:mysql *.*" for
all files and dirs (which were /var/lib
and /var/lib/mysql for me) everything worked out
fine. Hope it helps! 8-)

Posted by Justin Francis on Friday September 27 2002, @11:21am[Delete] [Edit]

Should be added to the instruction set above to
verify that your umask is set to 002: umask 002

Posted by Fery Tjhia on Wednesday October 16 2002, @11:34am[Delete] [Edit]

Typical problem with redhat 7.3 new installation:
mysql.host, host.frm.
Same as Justin Palamar above , but I did:
1. run mysql_install_db as root
2. chown mysql:mysql -R /var/lib/mysql/mysql

Posted by Magnus Sundberg on Wednesday April 16 2003, @10:46am[Delete] [Edit]

I run redhat 7.2 and want to upgrade to MySQL 4.0.12 using the rpm from MySQL AB and php/Apache from Redhat to have the simplest way of administrating my system.
I used the following path
rpm -e php
rpm -i php-4.1.2-7.3.6.src.rpm
cd /usr/src/redhat/SPECS
rpm -ba php.spec
cd ../RPMS/i386
rpm -iv php-4.1.2-7.3.6.i386.rpm php-mysql-4.1.2-7.3.6.i386.rpm

i.e. unisnstall the php rpm:s,
rebuild the php-rpm:s from the source rpm and reinstall the newly created php-rpms

P.S. The php rpm comes from redhat 7.3 so you can/will run into some dependency problems. You probably also need to install a few more packages, among those postgresql-devel and postgresql-libs :-(, to enable the build process.

Posted by Marko Hrastovec on Thursday April 17 2003, @10:44pm[Delete] [Edit]

I had problems with RPM's on one of RedHat 7.3 machine. I was upgrading from 3.23 to 4.0.

The new version obviously needs some more fields in tables in mysql database. Upgrade did not alter mysql database. 4.0 did not find all the fields it was looking for and therefore user permissions were not set. The result was no user has been able to access any tables. Only empty databases were seen.

The solution was to dump mysql database and then delete it. After that I upgraded to 4.0. Because mysql database was missing upgrade created a new one. I then inserted records from 3.23 with inserts that mysqldump provided. That way all user permissions were preserved.

Add your own comment.