Wednesday, September 17, 2008

Running MySQL 4 & MySQL 5 Concurrently

1.0. Download and install MySQL 5.x

1.1. Download the source code from http://dev.mysql.com/downloads/mysql/5.0.html#source

1.2. #tar -zxvf mysql.version.tgz

1.3. #cd mysql.version

1.4. # ./configure --prefix=/var/lib/mysql5 \
--with-unix-socket-path=/var/lib/mysql5/mysql5.sock \
--with-tcp-port=3307
1.5. #make
1.6. #make install

2.0. Create an appropriate cnf/ini file so that mysql will know where to place the data files and other configuration option.

2.1. #vi /etc/my5.cnf, below is a sample file.

# Example MySQL config file for large systems.

## This is for a large system with memory = 512M where the system runs mainly MySQL.
## You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /var/lib/mysql5/var) or
# ~/.my.cnf to set user-specific options.

## In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.# The following options will be passed to all MySQL clients

#[client]
#password = your_password
#port = 3307
#socket = /var/lib/mysql5/mysql5.sock

# Here follows entries for some specific programs
# The MySQL server

[mysqld]
port = 3307
socket = /var/lib/mysql5/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/mysqld_5.log
pid-file=/var/lib/mysql5/mysqld5.pid

2.2. :wq to save the file.

2.3. Run this for install database directory.

./scripts/mysql_install_db --defaults-file=/etc/my5.cnf --user=mysql

3.0. Enter this line in /etc/rc.local to pin mysql5 when system start

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

4.0. Now configure phpMyAdmin to access both the Server MySQL 4.x and 5.x. Below is a sample of config.inc.php file.

/* Servers configuration */
$i = 0;

/* Server DiademGW_MySQL-4 (cookie) [1] */
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['verbose'] = 'MySQL-4';

/* Server DiademGW_MySQL-5 (cookie) [2] */
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['port'] = '3307';
$cfg['Servers'][$i]['socket'] = '/var/lib/mysql5/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';

/* End of servers configuration */

$cfg['blowfish_secret'] = '475e8ba09cb6c4.57557095';
?>

No comments:

Powered By Blogger