同时运行MySQL 4和MySQL 5

同时运行MySQL 4和MySQL 5 本教程介绍如何在MySQL 4的系统上安装MySQL 5 已经开始。它也显示了...

同时运行MySQL 4和MySQL 5

本教程将介绍如何在MySQL 4已经运行的系统上安装MySQL 5。 它还显示如何配置phpMyAdmin来使用这两个数据库。

1下载并安装MySQL 5.x

http://dev.mysql.com/downloads/mysql/5.0.html#source下载源代码

tar -zxvf mysql.version.tgz
cd mysql.version
./configure --prefix=/var/lib/mysql5 \
             --with-unix-socket-path=/var/lib/mysql5/mysql5.sock \
             --with-tcp-port=3307
make
make install

2创建一个适当的cnf / ini文件,以便mysql将知道放置数据文件和其他配置选项的位置。

vi /etc/my5.cnf

以下是一个示例文件。

# 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

:wq保存文件。

运行安装数据库目录。

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

在系统启动时,在/etc/rc.local中输入这行代码以引导 mysql5:

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

3现在配置phpMyAdmin访问服务器MySQL 4.x和5.x. 以下是config.inc.php文件的示例。

<?php
/* 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';
?>