day1(多实例配置)-创新互联-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

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://kswsj.cn/article/jjpop.html

其他资讯