day1(多实例配置)
短信预约 -IT技能 免费直播动态提醒
数据库的安装路径:/usr/local/mysql
数据目录:/data/mysql/data
(此处mysql的解压就不再列出来了)
在原来的环境上已经有安装了一个实例port3306
在此处要新进2个实例(端口为3307,3308)
[root@master2 mysql]# pwd
/data/mysql
# mkdir data3307
# mkdir data3308
chown -R mysql:mysql .
# cd scripts/
# ls
mysql_install_db
./mysql_install_db --user=mysql datadir=/data/mysql/data3307
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/data3307/
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/data3308/
配置文件(/etc/my.cnf)
[mysqld_multi]
mysqld=/usr/local/mysql/bin/mysqld
mysqladmin=/usr/local/mysql/bin/mysqladmin
user=admin
password=123456
[mysqld3306]
port=3306
pid-file=/data/mysql/data/master2.pid
datadir=/data/mysql/data
basedir=/usr/local/mysql
socket=/tmp/mysql.sock
user = mysql
server-id = 3306
[mysqld3307]
socket=/tmp/mysql3307.sock
port=3307
datadir=/data/mysql/data3307
pid-file=/data/mysql/data/mysql3307.pid
basedir=/usr/local/mysql
user = mysql
server-id = 3307
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld3308]
socket=/tmp/mysql3308.sock
port=3308
datadir=/data/mysql/data3308
pid-file=/data/mysql/data/mysql3308.pid
basedir=/usr/local/mysql
user = mysql
server-id = 3308
启动三个mysql服务
mysqld_multi start 3306
mysqld_multi start 3307
mysqld_multi start 3308
#mysql -uroot -p123456 -S ./mysql.sock(3306端口的已经设置了密码了)
mysql -uroot -p -S ./mysql3307.sock #登录mysql
mysql -uroot -p -S ./mysql3308.sock
netstat -ntlp |grep mysql #查看mysql端口监听
[root@master2 lib]# netstat -ntlp |grep mysql
tcp 0 0 :::3307 :::* LISTEN 15878/mysqld
tcp 0 0 :::3308 :::* LISTEN 15968/mysqld
tcp 0 0 :::3306 :::* LISTEN 15819/mysqld
设置新密码
mysqladmin -uroot -S /tmp/mysql_3307.sock password 123456
mysqladmin -uroot -S /tmp/mysql_3308.sock password 123456
设置权限(3307,3308,3306)都要设置
grant all on *.* to admin@'%' identified by 'root' with grant option;
查看日志
cd /usr/local/mysql/share
# tail -f mysqld_multi.log
数据目录:/data/mysql/data
(此处mysql的解压就不再列出来了)
在原来的环境上已经有安装了一个实例port3306
在此处要新进2个实例(端口为3307,3308)
[root@master2 mysql]# pwd
/data/mysql
# mkdir data3307
# mkdir data3308
chown -R mysql:mysql .
# cd scripts/
# ls
mysql_install_db
./mysql_install_db --user=mysql datadir=/data/mysql/data3307
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/data3307/
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/data3308/
配置文件(/etc/my.cnf)
[mysqld_multi]
mysqld=/usr/local/mysql/bin/mysqld
mysqladmin=/usr/local/mysql/bin/mysqladmin
user=admin
password=123456
[mysqld3306]
port=3306
pid-file=/data/mysql/data/master2.pid
datadir=/data/mysql/data
basedir=/usr/local/mysql
socket=/tmp/mysql.sock
user = mysql
server-id = 3306
[mysqld3307]
socket=/tmp/mysql3307.sock
port=3307
datadir=/data/mysql/data3307
pid-file=/data/mysql/data/mysql3307.pid
basedir=/usr/local/mysql
user = mysql
server-id = 3307
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld3308]
socket=/tmp/mysql3308.sock
port=3308
datadir=/data/mysql/data3308
pid-file=/data/mysql/data/mysql3308.pid
basedir=/usr/local/mysql
user = mysql
server-id = 3308
启动三个mysql服务
mysqld_multi start 3306
mysqld_multi start 3307
mysqld_multi start 3308
#mysql -uroot -p123456 -S ./mysql.sock(3306端口的已经设置了密码了)
mysql -uroot -p -S ./mysql3307.sock #登录mysql
mysql -uroot -p -S ./mysql3308.sock
netstat -ntlp |grep mysql #查看mysql端口监听
[root@master2 lib]# netstat -ntlp |grep mysql
tcp 0 0 :::3307 :::* LISTEN 15878/mysqld
tcp 0 0 :::3308 :::* LISTEN 15968/mysqld
tcp 0 0 :::3306 :::* LISTEN 15819/mysqld
设置新密码
mysqladmin -uroot -S /tmp/mysql_3307.sock password 123456
mysqladmin -uroot -S /tmp/mysql_3308.sock password 123456
设置权限(3307,3308,3306)都要设置
grant all on *.* to admin@'%' identified by 'root' with grant option;
查看日志
cd /usr/local/mysql/share
# tail -f mysqld_multi.log
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341