做測試還是采用二進制方式安裝,簡單友善快速,在原環境安裝好的基礎上。
個人不喜歡采用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方式,或編寫啟動腳本。