您的位置:首页 > 数据库 > MySQL

同一台服务器安装两个mysql(不同端口)

2011-04-11 11:30 561 查看

mysql1:使用默认配置

root@localhost usr]# groupadd mysql
[root@localhost usr]# useradd -g mysql mysql
[root@localhost usr]# cd /usr/local
[root@localhost local]# tar -zxvf mysql-5.0.51.tar.gz
[root@localhost local]# cd mysql-5.0.51
[root@localhost mysql-5.0.51# ./configure --prefix=/usr/local/mysql
[root@localhost mysql-5.0.51]# make
[root@localhost mysql-5.0.51]# make install
[root@localhost mysql-5.0.51]# cd ../mysql
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql var
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# ./bin/mysqld_safe --user=mysql &
[root@localhost mysql]# ./bin/mysqladmin -uroot password mysql
[root@localhost mysql]# cp ../mysql-5.0.51/support-files/my-large.cnf /etc/my.cnf
[root@localhost mysql]# cp ../mysql-5.0.51/support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# chkconfig --level mysqld 345 on
[root@localhost mysql]# chkconfig --list mysqld
[root@localhost mysql]#



mysql2使用3307端口,配置文件为:/etc/my5.cnf

root@localhost usr]# groupadd mysql
[root@localhost usr]# useradd -g mysql mysql
[root@localhost usr]# cd /usr/local
[root@localhost local]# tar -zxvf mysql-5.0.51.tar.gz
[root@localhost local]# cd mysql-5.0.51
[root@localhost mysql-5.0.51# ./configure --prefix=/usr/local/mysql5
[root@localhost mysql-5.0.51]# make
[root@localhost mysql-5.0.51]# make install
[root@localhost mysql-5.0.51]# cd ../mysql
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql var
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# ./bin/mysqld_safe --user=mysql &
[root@localhost mysql]# ./bin/mysqladmin -uroot password mysql
[root@localhost mysql]# cp ../mysql-5.0.51/support-files/my-large.cnf /etc/my.cnf
[root@localhost mysql]# cp ../mysql-5.0.51/support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql]# chkconfig --add mysql5
[root@localhost mysql]# chkconfig --level mysql5 345 on
[root@localhost mysql]# chkconfig --list mysqld5
[root@localhost mysql]#

vi /etc/rc.d/init.d/mysql5

修改下面的内容:

conf=/etc/my5.cnf

$bindir/mysqld_safe --defaults-file=/etc/my5.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &



vi /etc/my5.cnf修改相关的端口

port = 3307

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐