Running MySQL 4 and MySQL 5 Concurrently

From Howtoforge.com’s article: Running MySQL 4 And MySQL 5 Concurrently

But I did in another way, because current release of CentOS / RHEL 5 already include MySQL 5 and I install MySQL 4 manually. I need a server with 2 MySQL version for development purpose: as current development is using MySQL 4 so I’ll configure it to use default port 3306 and for MySQL 5 will use port 3307.

First install CentOS with MySQL 5, afterthat configure MySQL 5 to use port 3307

# cp /usr/share/doc/mysql-server-5.0.22/my-medium.cnf /etc/my.cnf
# vi /etc/my.cnf
...
[client]
#password       = your_password
port            = 3307
socket          = /var/lib/mysql/mysql.sock

# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port            = 3307
socket          = /var/lib/mysql/mysql.sock
...
# chkconfig mysqld on
# service mysqld start

To add new mysql user you can read “Adding mysql users“, to change mysql’s root password use:

# /usr/bin/mysqladmin -u root password 'newpassword'

Now we are going to install MySQL 4

Download MySQL 4 source tarball (I am downloading from MirrorService)

# tar xzvf mysql-4.0.27.tar.gz
# cd mysql-4.0.27
# yum -y install libtermcap-devel gcc-c++ gcc
# echo '/* Linuxthreads */' >> /usr/include/pthread.h
# ./configure --prefix=/var/lib/mysql4 --with-unix-socket-path=/var/lib/mysql4/mysql4.sock --with-tcp-port=3306
# make
# make install
# cp /var/lib/mysql4/share/mysql/my-medium.cnf /etc/my4.cnf
# ./scripts/mysql_install_db --defaults-file=/etc/my4.cnf --user=mysql
# chown -R mysql.mysql /var/lib/mysql4
# echo "/var/lib/mysql4/bin/mysqld_safe --defaults-file=/etc/my4.cnf --user=mysql &" >> /etc/rc.local

To connect MySQL 4.0, go to folder /var/lib/mysql4/bin

# cd /var/lib/mysql4/bin
# ./mysqladmin -u root password 'newpassword'
# ./mysql --socket=/var/lib/mysql4/mysql4.sock

To connect MySQL 5.0, go to folder /var/lib/mysql4/bin

# mysql  --port=3307

After you specify root password you may need to connect using option -u and -p

SocialTwist Tell-a-Friend

Related posts:

  1. Running MySQLd as standalone application on Windows My friend asked me how to get MySQL running as...

One Response to “Running MySQL 4 and MySQL 5 Concurrently”

  1. centeng Says:

    artikel yang bagus,jadi ada bahan referensi untuk diuji coba di server gw
    thnx ya

Leave a Reply