2.8. Installing MySQL on Other Unix-Like Systems

MySQL 5.0

2.8. Installing MySQL on Other Unix-Like Systems

This section covers the installation of MySQL binary distributions that are provided for various platforms in the form of compressed tar files (files with a extension). See Section 2.1.2.5, “MySQL Binaries Compiled by MySQL AB”, for a detailed list.

To obtain MySQL, see Section 2.1.3, “How to Get MySQL”.

MySQL tar file binary distributions have names of the form -.tar.gz, where is a number (for example, ), and indicates the type of operating system for which the distribution is intended (for example, ).

In addition to these generic packages, we also offer binaries in platform-specific package formats for selected platforms. See Section 2.2, “Standard MySQL Installation Using a Binary Distribution”, for more information on how to install these.

You need the following tools to install a MySQL tar file binary distribution:

  • GNU to uncompress the distribution.

  • A reasonable tar to unpack the distribution. GNU tar is known to work. Some operating systems come with a pre-installed version of tar that is known to have problems. For example, Mac OS X tar and Sun tar are known to have problems with long filenames. On Mac OS X, you can use the pre-installed gnutar program. On other systems with a deficient tar, you should install GNU tar first.

If you run into problems and need to file a bug report, please use the instructions in Section 1.8, “How to Report Bugs or Problems”.

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

shell> 
shell> 
shell> 
shell> .tar.gz | tar xvf -
shell>  mysql
shell> 
shell> 
shell> 
shell> 
shell> 
shell> 

Note: This procedure does not set up any passwords for MySQL accounts. After following the procedure, proceed to Section 2.10, “Post-Installation Setup and Testing”.

A more detailed version of the preceding description for installing a binary distribution follows:

  1. Add a login user and group for mysqld to run as:

    shell> 
    shell> 
    

    These commands add the group and the 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 . If so, substitute the appropriate name in the following steps.

  2. Pick the directory under which you want to unpack the distribution and change location into it. In the following example, we unpack the distribution under . (The instructions, therefore, assume that you have permission to create files and directories in . If that directory is protected, you must perform the installation as .)

    shell> 
    
  3. Obtain a distribution file using the instructions in Section 2.1.3, “How to Get MySQL”. For a given release, binary distributions for all platforms are built from the same MySQL source distribution.

  4. Unpack the distribution, which creates the installation directory. Then create a symbolic link to that directory:

    shell> .tar.gz | tar xvf -
    shell>  mysql
    

    The tar command creates a directory named -. The command makes a symbolic link to that directory. This lets you refer more easily to the installation directory as .

    With GNU tar, no separate invocation of is necessary. You can replace the first line with the following alternative command to uncompress and extract the distribution:

    shell> .tar.gz
    
  5. Change location into the installation directory:

    shell> 
    

    You will find several files and subdirectories in the directory. The most important for installation purposes are the and subdirectories:

    • The directory contains client programs and the server. You should add the full pathname of this directory to your environment variable so that your shell finds the MySQL programs properly. See Appendix F, Environment Variables.

    • The directory contains the mysql_install_db script used to initialize the database containing the grant tables that store the server access permissions.

  6. If you have not installed MySQL before, you must create the MySQL grant tables:

    shell> 
    

    If you run the command as , you must use the option as shown. The value of the option should be 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 option.

    After creating or updating the grant tables, you need to restart the server manually.

  7. Change the ownership of program binaries to and ownership of the data directory to the user that you run mysqld as. Assuming that you are located in the installation directory (), the commands look like this:

    shell> 
    shell> 
    shell> 
    

    The first command changes the owner attribute of the files to the user. The second changes the owner attribute of the data directory to the user. The third changes the group attribute to the group.

  8. If you want MySQL to start automatically when you boot your machine, you can copy to the location where your system has its startup files. More information can be found in the script itself and in Section 2.10.2.2, “Starting and Stopping MySQL Automatically”.

  9. You can set up new accounts using the bin/mysql_setpermission script if you install the and Perl modules. For instructions, see Section 2.14, “Perl Installation Notes”.

  10. If you would like to use mysqlaccess and have the MySQL distribution in some non-standard location, you must change the location where mysqlaccess expects to find the mysql client. Edit the 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, a error will occur when you run mysqlaccess.

After everything has been unpacked and installed, you should test your distribution. To start the MySQL server, use the following command:

shell> 

If that command fails immediately and prints , you can find some information in the .err file in the data directory.

More information about mysqld_safe is given in Section 5.4.1, “mysqld_safe — MySQL Server Startup Script”.

Note: 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.10, “Post-Installation Setup and Testing”.