网上大部分文档都是用mysql_multi来实现一个机器上跑多个mysql实例的。但是不知道为什么,我按照他们的做法就是不成功。以后再尝试吧。
现在就用最简单的方法,在一个机器上安装两个mysql。安装方式同安装一个mysql没什么太大区别。
tar -zxvf mysql-5.6.24.tar.gz
cd mysql-5.6.24
第一个Mysql,端口3306:
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
make
make install
第二个Mysql,端口3307:
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql3307 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql3307/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql3307/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3307
make
make install
更改属主:
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data
chown -R mysql:mysql /usr/local/mysql3307
chown -R mysql:mysql /usr/local/mysql3307/data
初始化:
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql
cd /usr/local/mysql3307
./scripts/mysql_install_db --user=mysql
添加到服务列表:
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf3306
cp /usr/local/mysql3307/support-files/mysql.server /etc/init.d/mysql3307
cp /usr/local/mysql3307/support-files/my-default.cnf /etc/my.cnf3307
启服务:
service mysql start
service mysql3307 start
查看服务是否启动:
netstat -tlnap|grep mysql
更改root用户的密码:
./usr/local/mysql/bin/mysqladmin -u root password 'root';
./usr/local/mysql3307/bin/mysqladmin -u root password 'root';
登陆:
mysql -S /usr/local/mysql/mysql.sock -P 3306 -uroot -p
mysql -S /usr/local/mysql3307/mysql.sock -P 3307 -uroot -p
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28497416/viewspace-2123929/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28497416/viewspace-2123929/