资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

day1(多实例配置)-创新互联

数据库的安装路径:/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

网站题目:day1(多实例配置)-创新互联
文章路径:http://cdkjz.cn/article/jjpop.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220