Multiple Mysql Version on Same Server

Mysql

We are running a production server in US. This production server was running on RHEL4 with Mysql 4.1.22. Server was set up 8 years ago. The web projects we are having requires the Mysql version 5.1.65. So after performing R&D on my local test server, i finally configured 2nd Mysql version on that same server. Today i am going to show you how i did that.
But before proceeding you need to make sure that you have already done the following :

  • Taken backup of existing Mysql 4 which include ‘/var/lib/mysql’ and ‘/etc/my.cnf’ so that in case of any mis-configuration, we have the backup
  • Do not use Redhat RPM’s as they will require a lot of dependencies and can make changes in your existing Mysql 4 settings/configration.

Keep in mind:

  • Mysql 5 should have different data directory,Port number, Socket and PID file.
  • Do not make changes in default ‘/etc/my.cnf’ instead create separate Mysql5 configuration file like ‘/etc/my5.cnf’.

So if you have taken these precautions,you can proceed next.

Now Lets start:

Step 1. Download the desired Mysql version. In my case i have downloaded Mysql-5.1.65.tar.gz.

Step2. Extract tar file and change to the directory.

[root@Production ~]# tar Mysql-5.1.65.tar.gz

[root@Production ~]# cd Mysql-5.1.65

Step3. Now compile Mysql with following options.

[root@Production Mysql-5.1.65]# ./configure –prefix=/var/lib/mysql5.1.65 –with-unix-socket-path=/var/lib/mysql5.1.65/mysql5.sock –with-tcp-port=3307

[root@Production Mysql-5.1.65]# make && make install

Step4. Now create config file for Mysql 5 and add below mentioned details.

[root@Production Mysql-5.1.65]# vim /etc/my5.cnf

[mysqld]
port = 3307
socket = /var/lib/mysql5.1.65/mysql5.sock
old_passwords=1
skip-locking
key_buffer = 128M
max_allowed_packet = 1M
table_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
[mysql.server]
user=mysql
[mysql]
default-character-set=latin1
[mysqld_safe]
err-log=/var/log/mysqld5.1.65.log

Note: You can also copy predefined config file from directory ‘support-files’

[root@Production Mysql-5.1.65]# cp support-files/my-medium.conf /etc/my5.cnf

Step5. Now install all needed database files.

[root@Production Mysql-5.1.65]# cd script

[root@Production script]# ./mysql_install_db –defaults-file=/etc/my5.cnf –user=mysql &

Step6. Now start Mysql daemon with ‘mysqld_safe’

[root@Production script]# /var/lib/mysql5.1.65/bin/mysqld_safe –defaults-file=/etc/my5.cnf –user=mysql &

Step7. Copy above command in ‘/etc/rc.local’ so that even after reboot mysql daemon keeps running.

[root@Production script]# vim /etc/rc.local

/var/lib/mysql5.1.65/bin/mysqld_safe –defaults-file=/etc/my5.cnf –user=mysql &

Add aboove command in /etc/rc.local to start this at boot time also.

Step8. Change the Owner of mysql direcoty and start the new mysql 5 server.

[root@Production script]# chown -R mysql:mysql /var/lib/mysql5.1.65

[root@Production script]# /var/lib/mysql5.1.65/share/mysql/mysql.server start

Thats it. You have successfully started the mysql 5 server. Now just set the mysqladmin root password, to start working.

[root@Production script]# /var/lib/mysql5.1.65/bin/mysqladmin -u root password ‘redhat1’

Add Multiple Mysql Version in PHPMYADMIN

Open Config.inc.php file of phpmyadmin folder and add following lines

[root@Production ~]# vim /var/www/html/phpmyadmin/config.inc.php

/* Authentication type */
$cfg[‘Servers’][$i][‘auth_type’] = ‘cookie’;
/* Server parameters */
$cfg[‘Servers’][$i][‘host’] = ‘localhost’;
$cfg[‘Servers’][$i][‘connect_type’] = ‘tcp’;
$cfg[‘Servers’][$i][‘compress’] = false;
/* Select mysql if your server does not have mysqli */
$cfg[‘Servers’][$i][‘extension’] = ‘mysqli’;
$cfg[‘Servers’][$i][‘AllowNoPassword’] = false;
/* Server DiademGW_MySQL-5 (cookie) [2] */
$i++;
$cfg[‘Servers’][$i][‘host’] = ‘localhost’;
#$cfg[‘Servers’][$i][‘extension’] = ‘mysql.5.65’;
$cfg[‘Servers’][$i][‘port’] = ‘3307’;
$cfg[‘Servers’][$i][‘socket’] = ‘/var/lib/mysql5.1.65/mysql5.sock’; /*actual socket path*/
$cfg[‘Servers’][$i][‘connect_type’] = ‘socket’;
$cfg[‘Servers’][$i][‘compress’] = false;
$cfg[‘Servers’][$i][‘auth_type’] = ‘cookie’;
$cfg[‘Servers’][$i][‘verbose’] = ‘MySQL-5.1.65’;

You can leave a response, or trackback from your own site.

Leave a Reply