做测试还是采用二进制方式安装,简单方便快速,在原环境安装好的基础上。
个人不喜欢采用mysqlmulti方式配置多实例,还是采用多实例多进程方式配置。
# mkdir -p /usr/local/mysql/mysql3307
# chown mysql:mysql /usr/local/mysql/mysql3307
初始化实例目录
# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/mysql3307
(1) 修改现有配置文件名my.cnf修为3306.cnf,并复制一个配置文件名为3307.cnf
(2) 3306.cnf配置文件修改,端口,sock位置,pid位置,datadir位置等。
[client]
port = 3306
socket = /tmp/mysql3306.sock
[mysqld]
socket = /tmp/mysql3306.sock
datadir = /usr/local/mysql/data
(3) 3307.cnf配置文件修改
port = 3307
socket = /tmp/mysql3307.sock
socket = /tmp/mysql3307.sock
datadir = /usr/local/mysql/mysql3307
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/3306.cnf 2>&1 >/dev/null &
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/3307.cnf 2>&1 >/dev/null &
# /usr/local/mysql/bin/mysql -u root -p -p 3306 -s /tmp/mysql3306.sock
# /usr/local/mysql/bin/mysql -u root -p -p 3307 -s /tmp/mysql3307.sock
修改3307实例密码:
# /usr/local/mysql/bin/mysqladmin -u root password 'admin' -s /tmp/mysql3307.sock #设置管理员密码
[root@test ~]# mysql -uroot -p -s /tmp/mysql3306.sock
enter password:
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 14
server version: 5.6.24-log source distribution
copyright (c) 2000, 2015, oracle and/or its affiliates. all rights reserved.
oracle is a registered trademark of oracle corporation and/or its
affiliates. other names may be trademarks of their respective
owners.
type 'help;' or '\h' for help. type '\c' to clear the current input statement.
mysql>
mysql> \q
bye
[root@test ~]# mysql -uroot -p -s /tmp/mysql3307.sock
your mysql connection id is 15
affiliates. other names may be trademarks of their respective owners.
mysql>
指定端口号也是可以访问的:
mysql -uroot -p -h127.0.0.1 -p3307
# /usr/local/mysql/bin/mysqladmin -u root -p -p 3306 -s /tmp/mysql3306.sock shutdown
# /usr/local/mysql/bin/mysqladmin -u root -p -p 3307 -s /tmp/mysql3307.sock shutdown
或采用kill方式,或编写启动脚本。