首页 > 代码库 > MySQL数据库多实例配置
MySQL数据库多实例配置
----------------------------------------------------------------
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
文件下有这个代表成功
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
其他的端口一样修改
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/
其他的端口同理修改
8 然后启动各个mysql实例
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
好了mysql多实例现在已经配置完毕。
本文出自 “生活的理想为了理想的生活” 博客,请务必保留此出处http://lampol.blog.51cto.com/11662628/1853094
MySQL数据库多实例配置