Mysql 5 6 x多例項配置

2021-09-21 20:10:59 字數 2843 閱讀 2571

做測試還是採用二進位制方式安裝,簡單方便快速,在原環境安裝好的基礎上。    

mysql-5.6.x二進位制版本安裝記錄 

個人不喜歡採用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]    

port        = 3306     

socket      = /tmp/mysql3306.sock     

datadir     = /usr/local/mysql/data

(3) 3307.cnf配置檔案修改

[client]    

port        = 3307     

socket      = /tmp/mysql3307.sock

[mysqld]    

port        = 3307     

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  #設定管理員密碼

3306登入示例1:

[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

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     

bye3307登入示例:

[root@test ~]# mysql -uroot -p  -s /tmp/mysql3307.sock    

enter password:     

welcome to the mysql monitor.  commands end with ; or \g.     

your mysql connection id is 15     

server version: 5.6.24-log source distribution

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 -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方式,或編寫啟動指令碼。

MySQL 5 6 x修改root密碼操作

軟體名稱 mysql 5.6.43 winx64 提取碼 7hy4 1.開啟mysql目錄 綠色版 不是安裝目錄 把my default.ini檔案複製乙份得到my.ini檔案。開啟my.ini檔案,在檔案的最後新增一行 skip grant tables 儲存並關閉檔案 2.重啟mysql服務 以...

mysql多例項配置

1 mysql安裝參考 2 建立 例項的資料檔案目錄 cd data mkdir p data 3 copy mysql軟體到對應例項目錄下 cd data cp r mysql dbdata1 cp r mysql dbdata2 4 編輯配置檔案my.cnf cd data dbdata1 vi...

mysql多例項配置 MySQL多例項資料庫配置

mysql多例項資料庫配置 1 登入進入mysql,在mysql 5.7.18 bin目錄下執行命令 mysql uroot p s usr local mysql 5.7.18 data 3307 mysql.sock 其中 p 是指定密碼,如果沒有密碼則可以不寫 p,s是指定sock檔案,mys...