欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

linux下安装第二个mysql实例过程

程序员文章站 2022-05-30 19:04:20
...

tar zxvf mysql-5.5.3-m3.tar.gz cd mysql-5.5.3-m3/ ./configure --prefix=/usr/local/mysql2/ --with-tcp-port=3307 --with-unix-socket-path=/tmp/mysql2.sock --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big


tar zxvf mysql-5.5.3-m3.tar.gz
cd mysql-5.5.3-m3/

./configure --prefix=/usr/local/mysql2/ --with-tcp-port=3307 --with-unix-socket-path=/tmp/mysql2.sock --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg

make && make install

cp /usr/local/mysql2/share/mysql/my-medium.cnf /etc/my2.cnf

cp /usr/local/mysql2/share/mysql/mysql.server /etc/init.d/mysql2



修改服务文件


vi /etc/rc.d/init.d/mysql2



将引用的配置文件名称由my.cnf改为当前要使用的配置文件my2.cnf,将my.cnf改成my2.cnf


# Try to find basedir in /etc/my.cnf
conf=/etc/my.cnf
print_defaults=
if test -r $conf
then



在$bindir/mysqld_safe中添加--defaults-file=/etc/my2.cnf

修改成下面


# may be overwritten at next upgrade.
$bindir/mysqld_safe --defaults-file=/etc/my2.cnf --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &



保存。

初始化数据库


/usr/local/mysql2/bin/mysql_install_db --defaults-file=/etc/my2.cnf --basedir=/usr/local/mysql2/ --datadir=/usr/local/mysql2/var/ --user=mysql




chown -R mysql /usr/local/mysql2/var
chgrp -R mysql /usr/local/mysql2/.
chmod 755 /etc/init.d/mysql2
chkconfig --level 345 mysql2 on
service mysql2 start



至此安装完毕,可以启动一下,看是否有该进程


netstat -tlnap | grep mysql





/usr/local/mysql2/bin/mysql -uroot -p --socket=/tmp/mysql2.sock




change master to master_host='0.0.0.0', master_user='replication',master_password='00000', master_log_file='mysql-bin.000005', master_log_pos=107,MASTER_PORT=3306;



要指定端口,要不用的是本实例默认端口。


Tags - mysql , mysql安装