首页 > 代码库 > 如何在多实例基础上再添加一个mysql的实例
如何在多实例基础上再添加一个mysql的实例
1)创建数据文件所需的目录
# mkdir -p /data/3308/data # cp /data/3306/my.cnf /data/3308 # cp /data/3306/mysql /data/3308
2)配置权限
# chown mysql.mysql /data/3308 -R # chown root.root /data/3308/mysql # chmod 700 /data/3308/mysql
3)修改数据配置文件及启动脚本
# sed -i ‘s/3306/3308/g‘ /data/3308/my.cnf # sed -i ‘s/server-id = 1/server-id = 8/g‘ /data/3308/my.cnf # cat my.cnf | grep id pid-file = /data/3308/mysql.pid server-id = 8 pid-file=/data/3308/mysqld.pid # sed -i ‘s/3306/3308/g‘ /data/3308/mysql # cd /application/mysql/scripts/ # ./mysql_install_db --datadir=/data/3308/data --basedir=/application/mysql --user=mysql # /data/3308/mysql start Starting MySQL... # echo $? 0
4)检查数据库的运行情况
# netstat -tunlp | grep 330* tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 4052/mysqld tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 4048/mysqld tcp 0 0 0.0.0.0:3308 0.0.0.0:* LISTEN 5502/mysqld
5)配置数据库开机自动启动
# echo "/data/3308/mysql start">>/etc/rc.local # tail -4 /etc/rc.local 显示的结果如下: # mysql multi instances startup /data/3306/mysql start /data/3307/mysql start /data/3308/mysql start
6)初始化数据库
设置mysql初始密码: # mysqladmin -u root -S /data/3308/mysql.sock password ‘redhat12345‘ # mysql -u root -S /data/3308/mysql.sock -predhat12345 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.5.32-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 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.
本文出自 “冰冻vs西瓜” 博客,请务必保留此出处http://molewan.blog.51cto.com/287340/1860235
如何在多实例基础上再添加一个mysql的实例
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。