最新消息:时间抓起来说是金子,抓不住就是流水。

Centos 6.3 安装两个Mysql

MySql 老子黑牵翻 4385浏览 0评论

在centos 6.3下安装两个Mysql其实难点就在于启动的时候选用不同的配置文件,如果两个MYSQL启动,有用到/etc/my.cnf那就会产生端口冲突,文件冲突等问题,所以,我们需要更改mysql的启动服务文件,在mysql启动服务文件里面,有2个地方需要修改,现在我来说下我的安装步骤

安装mysql5.5.25
tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4/
./configure  –prefix=/usr
gmake
gmake install

tar zxvf bison-2.4.3.tar.gz
cd bison-2.4.3
./configure
make
make install

Groupadd mysql
Useradd -g mysql mysql
cmake -DMYSQL_USER=mysql -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5 -DMYSQL_DATADIR=/data/mysql5.5/data -DMYSQL_UNIX_ADDR=/data/mysql5.5/mysql.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_SSL=yes -DWITH_DEBUG=0 
make
make install
/usr/local/mysql5.5/scripts/mysql_install_db –basedir=/usr/local/mysql5.5/ –datadir=/data/mysql5.5/data –user=mysql
cd /usr/local/mysql5.5/support-files/
cp my-innodb-heavy-4G.cnf /etc/my5.5.cnf
cp mysql.server /etc/rc.d/init.d/mysql5.5
chown mysql:mysql /etc/rc.d/init.d/mysql5.5
chmod +w /etc/rc.d/init.d/mysql5.5

然后我们西药修改/etc/rc.d/init.d/mysql5.5
vi /etc/rc.d/init.d/mysql5.5
把conf=/etc/my.cnf 改成conf=/etc/my5.5.cnf
把$bindir/mysqld_safe –datadir="$datadir" –pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
改成
$bindir/mysqld_safe –defaults-file=/etc/my5.5.cnf –datadir="$datadir" –pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
就这两个地方需要修改,然后保存
然后我们修改/etc/my5.5.cnf下的端口,启动mysql5.5就OK了

安装mysql5.0.77
同样是编译安装
./configure –prefix=/usr/local/mysql5.0 –localstatedir=/data/mysql5.0 –with-charset=utf8 –with-extra-charsets=all –with-berkeley-db –with-innodb –enable-assembler –with-pthread –enable-thread-safe-client –with-client-ldflags=-all-static
make
make install
/usr/local/mysql5.0/bin/mysql_install_db –user=mysql
cp support-file/my-innodb-heavy-4G.cnf /etc/my5.0.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysql5.0
在这里我们依然需要修改/etc/rc.d/init.d/mysql5.0文件
vi /etc/rc.d/init.d/mysql5.0
把conf=/etc/my.cnf 改成conf=/etc/my5.0.cnf
把$bindir/mysqld_safe –datadir="$datadir" –pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
改成
$bindir/mysqld_safe –defaults-file=/etc/my5.0.cnf –datadir="$datadir" –pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
保存,然后修改/etc/my5.0.cnf把端口修改了,一定不能和my5.5.cnf设置的端口一样,然后保存配置文件
就可以正常启动mysql5.0
chmod +x /etc/rc.d/init.d/mysql5.0

转载请注明:LINUX服务器运维架构技术分享 » Centos 6.3 安装两个Mysql

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址