1) The directory required to create the data file
# mkdir-p/data/3308/data# cp/data/3306/my.cnf/data/3308# cp/data/3306/mysql/data/3308
2) Configure permissions
# chown mysql.mysql/data/3308-r# chown root.root/data/3308/mysql # chmod 700/data/3308/mysql
3) Modify the data configuration file and startup script
# 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 idpid-file =/data/3308/mysql.pidserver-id = 8pid-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 startstarting mysql...# Echo $?0
4) Check the operation of the database
# 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) Configure the database to boot automatically
# echo "/data/3308/mysql start" >>/etc/rc.local# tail-4/etc/rc.local The results shown are as follows: # MySQL Multi instances startup/data/ 3306/mysql start/data/3307/mysql start/data/3308/mysql Start
6) Initializing the database
Set MySQL initial password: # mysqladmin-u root-s/data/3308/mysql.sock password ' redhat12345 ' # mysql-u root-s/data/3308/mysql.sock- Predhat12345welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 4Server version:5.5.32-log Source distributioncopyright (c), +, Oracle and/or I TS affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
This article is from the "Frozen vs watermelon" blog, so be sure to keep this source http://molewan.blog.51cto.com/287340/1860235
How to add another instance of MySQL on a multi-instance basis