----------------------------------------------------------------

MySQL  5.5.48

-----------------------------------------------------------------

1 创建数据库文件

mkdir -p  /usr/local/mysql/data/3306

mkdir -p  /usr/local/mysql/data/3307

mkdir -p  /usr/local/mysql/data/3308


chown -R mysql:mysql /usr/local/mysql/data/3306

chown -R mysql:mysql /usr/local/mysql/data/3307

chown -R mysql:mysql /usr/local/mysql/data/3308

2 初始化数据库

/usr/local/mysql/scripts/mysql_install_db  --basedir=/usr/local/mysql  --datadir=/usr/local/mysql/data/3306  --user=mysql

/usr/local/mysql/scripts/mysql_install_db  --basedir=/usr/local/mysql  --datadir=/usr/local/mysql/data/3307  --user=mysql

/usr/local/mysql/scripts/mysql_install_db  --basedir=/usr/local/mysql  --datadir=/usr/local/mysql/data/3308  --user=mysql

wKioL1fbfNuTCR8SAAAaUV8RpL4983.png

文件下有这个代表成功

3 拷贝mysql的配置文件

cp /usr/local/mysql/support-files/my-huge.cnf   /usr/local/mysql/data/3306/my.cnf

cp /usr/local/mysql/support-files/my-huge.cnf   /usr/local/mysql/data/3307/my.cnf

cp /usr/local/mysql/support-files/my-huge.cnf   /usr/local/mysql/data/3308/my.cnf

4 修改配置文件 vim  my.cnf

wKioL1fbfuLAn6t4AABTOwT4zcE618.png

其他的端口一样修改

5 复制mysql启动文件到/etc/init.d/下面

cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql3306

cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql3307

cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql3308

6 给mysql赋权限

chmod 755 /etc/init.d/mysql3306

chmod 755 /etc/init.d/mysql3307

chmod 755 /etc/init.d/mysql3308

7 修改启动文件 vi /etc/init.d/

wKioL1fbginQe90RAABLVmiT1k8513.png

wKiom1fbgimzD9waAAAxKfNSkQ0156.png

其他的端口同理修改

8 然后启动各个mysql实例

wKioL1fbhoGDQihtAADV8emOsV8186.png

 9然后添加用户密码

/usr/local/mysql/bin/mysqladmin -uroot password lampol -S /tmp/mysql3306.sock

/usr/local/mysql/bin/mysqladmin -uroot password lampol -S /tmp/mysql3307.sock

/usr/local/mysql/bin/mysqladmin -uroot password lampol -S /tmp/mysql3308.sock

10 登录的时候要指定sock

wKioL1fbhb_i_262AABeLY1GHkc690.png

好了mysql多实例现在已经配置完毕。