HOWTO: Installing and running MySQL 4.0.20, 4.1.2-alpha and 5.0.0-alpha on same RH Linux box

Posted : June 1, 2004 at 12:25 pm [America/Los_Angeles]

Here’s what I intend to do:

1. Install the various MySQL instances from source so that they can happily co-exist in their logically and mutually exclusive world

2. Facilitate easy stopping and starting of the services

3. Set up the various instances in a way that makes installing newer versions alongside the others is a trivial task

The directory structure that I prefer is as follows:

Installation file/folder(s):
------------------------------
/usr/local/mysql/4.0.20
/usr/local/mysql/4.1.2-alpha
/usr/local/mysql/5.0.0-alpha

Configuration file/folder(s):
---------------------------------
/etc/mysql/4.0.20/my.cnf
/etc/mysql/4.1.2-alpha/my.cnf
/etc/mysql/5.0.0-alpha/my.cnf

Data and Log file/folder(s):
--------------------------------
/dbroot/mysql/4.0.20/data, /dbroot/mysql/4.0.20/logs, /dbroot/mysql/4.0.20/var
/dbroot/mysql/4.1.2-alpha/data, /dbroot/mysql/4.1.2-alpha/logs, /dbroot/mysql/4.1.2-alpha/var
/dbroot/mysql/5.0.0-alpha/data, /dbroot/mysql/5.0.0-alpha/logs, /dbroot/mysql/5.0.0-alpha/var

Service startup/shutdown executable(s):
----------------------------------------------
/etc/rc.d/init.d/mysql4
/etc/rc.d/init.d/mysql41
/etc/rc.d/init.d/mysql5

Before we start with the usual steps of compiling and installing MySQL, let’s first do a few pre-installation steps:

1. Create a /downloads folder and download the 3 binaries:
   mysql-4.0.20.tar.gz
   mysql-4.1.2-alpha.tar.gz
   mysql-5.0.0-alpha.tar.gz

2. Untar/Unzip it using the following commands:
   (prompt)>tar -xvzf mysql-x.x.x.tar.gz
   This step should create 3 seperate folders in /downloads for the 3 different binaries

3. Download and save customized ‘configure’ scripts in the path shown below:
   /downloads/mysql-4.0.20/mysql-configure
   /downloads/mysql-4.1.2-alpha/mysql-configure
   /downloads/mysql-5.0.0-alpha/mysql-configure

3. Create a unix account called mysql:
   (root-prompt)>useradd -s /sbin/nologin -r -d /dev/null mysql

   Note:
   ——
   I tend to use the same unix id for all 3 MySQL instances.

4. Setup the following folders:
   (root-prompt)>mkdir -p /etc/mysql/4.0.20
   (root-prompt)>mkdir -p /etc/mysql/4.1.2-alpha
   (root-prompt)>mkdir -p /etc/mysql/5.0.0-alpha

5. Download and save the service startup/shutdown files in the path shown below:
   /etc/rc.d/init.d/mysql4
   /etc/rc.d/init.d/mysql41
   /etc/rc.d/init.d/mysql5

6. Set up the services:
   (root-prompt)>chkconfig –level 345 mysql4 on
   (root-prompt)>chkconfig –level 345 mysql41 on
   (root-prompt)>chkconfig –level 345 mysql5 on

7. Download and save mysql configuration files in the path shown below:
   /etc/mysql/4.0.20/my.cnf
   /etc/mysql/4.1.2-alpha/my.cnf
   /etc/mysql/5.0.0-alpha/my.cnf

Here’s a quick look at the steps (using mysql-4.0.20.tar.gz as an example). You will repeat the same steps for 4.1.2-alpha and 5.0.0-alpha. Just
replace 4.0.20 with 4.1.2-alpha or 5.0.0-alpha in the steps outlined below:

1. (prompt)>wget http://mysql.mirrors.pair.com/Downloads/MySQL-4.0/mysql-4.0.20.tar.gz
2. (prompt)>cd mysql-4.0.20
3. (prompt)>./mysql-configure
4. (prompt)>make
5. (root-prompt)>make install
6. (root-prompt)>scripts/mysql_install_db
7. (root-prompt)>cd /db/mysql/4.0.20/data
8. (root-prompt)>chown -R mysql.mysql *
9. (root-prompt)>service mysql4 start

    Note:
    ------
    Replace "mysql4" with "mysql41" or "mysql5" depending upon whether you're attempting
    to start MySQL version 4.1.2-alpha or 5.0.0-alpha instance

10. (prompt)>/usr/local/mysql/4.0.20/bin/mysqladmin -u root password "<root-password>"
11. If you would like to enable access to root account of your MySQL from other hosts,
    run the following:
    (prompt)>/usr/local/mysql/4.0.20/bin/mysql -u root -p
    (mysql)>use mysql;
    (mysql)>GRANT ALL ON *.* TO root@"%" IDENTIFIED BY "<root-password>";
    (mysql)>exit;

    Security Note:
    ----------------
    You might want to enable root to access the MySQL instance from
    'a' host and not 'any' host (%)
12. To confirm that things actually did work as per plan, you can run the ps -aux command
    and look for mysql entries. You can also check the /dbroot/mysql/4.0.20/logs/error.log file
    for startup messages.

After repeating the steps for MySQL 4.1.2-alpha and MySQL-5.0.0-alpha, if you’re lucky and patient, you should have all three MySQL versions (and the goodies that come with it) ready to serve you

Note:

The entries with (root-prompt)> next to it signifies that those commands must be run with root privileges. Of course, you could run all these commands logged in as root.

- Anand

Viewed: 1607 times

2 Comments

Are you going to have a new version of “How Do I : Setup a basic Linux Box with Web based Application Support” sometime in the near future ?

Posted by: Devesh at June 1, 2004 @ 3:58 pm

:-)

I am not sure if a blog’s format would encourage such an entry Debu, as it probably would need a few pages worth of content. However, I do plan to keep documenting my HOWTOs in smaller chunks, such as this one.

HTH

Posted by: Anand Sharma at June 1, 2004 @ 6:31 pm