mysql5.7.14多实例安装
一、單實例安裝mysql5.7.14
1.1、查看是否安裝過mysql
[root@server136 ~]# ps -ef | grep mysql*
1.2、解壓mysql軟件包
[root@server136 ~]#tar zxvf mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz?
1.3、新建mysql用戶名和組
[root@server136 ~]#groupadd mysql
[root@server136 ~]#useradd -g mysql -r mysql ?#r代表新建系統用戶不能登錄
1.4、把mysql ?copy到/usr/local并重命名為mysql
[root@server136 ~]#?cp -R mysql-5.7.14-linux-glibc2.5-x86_64 /usr/local/
[root@server136 ~]#mv mysql-5.7.14-linux-glibc2.5-x86_64/ mysql
或
[root@server136 ~]# ln -sv mysql-5.7.14-linux-glibc2.5-x86_64 /usr/local/mysql/
1.5、建立數據文件夾,并更改屬主和屬組
[root@server136 ~]#mkdir -p /data/{3306,3307,3308}
[root@server136 ~]#chown -R mysql.mysql /usr/local/mysql/
[root@server136 ~]#chown -R mysql.mysql /data/
1.6、配置環境
[root@server136 ~]#echo "export PATH=$PATH:/usr/local/mysql/bin/" >>/etc/profile
[root@server136 ~]#source /etc/profile
1.7、初始化安裝mysql;--initialize-insecure這個參數代表不設密碼
[root@server136 ~]#/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/3306/
1.8、cp配置和啟動文件,并編輯my.cnf
[root@server136 ~]#?cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf?
[root@server136 ~]#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@server136 ~]#vi /etc/my.cnf?
[mysqld]
basedir = /usr/local/mysql
datadir = /data/3306
port = 3306
server_id = 1
socket =/data/3306/mysql.sock
symbolic-links = 0
character_set_server = utf8
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket=/data/3306/mysql.sock
1.9、啟動數據庫并設置密碼
[root@server136 ~]#/etc/init.d/mysqld start
[root@server136 ~]#mysql
mysql> update mysql.user set authentication_string=password('lila3306') where user='root';
mysql> flush privileges;
mysql> exit
二、多實例配置
2.1、cp多實例腳本服務到/etc/init.d,并重命名
[root@server136 ~]#cp /usr/local/mysql/support-files/mysqld_multi.server /etc/init.d/mysqld_multi
2.2、初始化安裝另外兩個數據庫
[root@server136 ~]#/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/3307/
[root@server136 ~]#/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/3308/
2.3、配置多實例數據庫配置文件
[root@server136 ~]# vi /etc/my.cnf?
[mysqld_multi]
mysqld=/usr/local/mysql/bin/mysqld_safe
mysqladmin=/usr/local/mysql/bin/mysqladmin
log=/data/mysql_multi.log
user = root
password = redhat
[mysqld3306]
basedir=/usr/local/mysql
datadir=/data/3306
port=3306
server_id=1
socket=/data/3306/mysql.sock
symbolic-links=0
character_set_server=utf8
pid-file=/data/3306/mysql.pid
log_error=/data/3306/3306.err
?
[mysqld3307]
datadir=/data/3307
port=3307
socket=/data/3307/mysql.sock
symbolic-links=0
character_set_server=utf8
pid-file=/data/3307/mysql.pid
log_error=/data/3307/3307.err
[mysqld3308]
datadir=/data/3308
port=3308
socket=/data/3308/mysql.sock
symbolic-links=0
character_set_server=utf8
pid-file=/data/3308/mysql.pid
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
2.4、啟動多實例,并查看服務是否啟動
[root@server136 ~]# /etc/init.d/mysqld_multi start
[root@server136 ~]# /etc/init.d/mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld3306 is running
MySQL server from group: mysqld3307 is running
MySQL server from group: mysqld3308 is running
[root@server136 ~]#?
2.5、登錄數據庫(注意,必須跟端口號和主機地址,否則會報錯)
[root@server136 ~]# mysql -uroot -P3307 -h127.0.0.1 -p
轉載于:https://blog.51cto.com/12565547/1896777
總結
以上是生活随笔為你收集整理的mysql5.7.14多实例安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用redis的发布订阅模式实现消息队列
- 下一篇: C# 正则表达式类 Match类和Gro