1.准备用户
[root@Centos7 ~]#mkdir /data/mysql
[root@Centos7 ~]#useradd -r -s /sbin/nologin -d /data/mysql mysql
2.解压缩
[root@Centos7 ~]#tar xvf mariadb-10.2.25-linux-x86_64.tar.gz -C /usr/local/
[root@Centos7 ~]#cd /usr/local/
[root@Centos7 local]#ln -s mariadb-10.2.25-linux-x86_64/ mysql
3.更改权限
[root@Centos7 local]#chown -R root.root mysql/
4.创建所需文件夹
[root@Centos7 ~]#mkdir /mysql/{3306,3307,3308}/{data,bin,log,socket,pid,etc} -pv
[root@Centos7 ~]#tree /mysql
5.安装库 (二进制提前创建用户)
[root@Centos7 mysql]#pwd
/usr/local/mysql
[root@Centos7 mysql]#scripts/mysql_install_db --datadir=/mysql/3306/data/ --user=mysql
[root@Centos7 mysql]#scripts/mysql_install_db --datadir=/mysql/3307/data/ --user=mysql
7.赋予权限
[root@Centos7 ~]#chown -R mysql.mysql /mysql/
8.准备配置文件 记得改权限
修改my.cnf
[root@Centos7 mysql]#vim /mysql/3306/etc/my.cnf
[root@Centos7 ~]#chown mysql.mysql /mysql/3306/etc/my.cnf
[root@Centos7 ~]#chmod +x /mysql/3306/etc/my.cnf
[root@Centos7 mysql]#vim /mysql/3307/etc/my.cnf
修改mysqld
[root@Centos7 ~]#vim /mysql/3306/bin/mysqld
[root@Centos7 ~]#chmod +x /mysql/3306/bin/mysqld
[root@Centos7 ~]#chown mysql.mysql /mysql/3306/bin/mysqld
[root@Centos7 ~]#cp /mysql/3306/bin/mysqld /mysql/3307/bin/mysqld
9.加入还环境变量
[root@Centos7 bin]#echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@Centos7 bin]#. /etc/profile.d/mysql.sh
[root@Centos7 bin]#mysql -S /mysql/3306/socket/mysql.sock
mysql 二进制多实例安装
最新推荐文章于 2023-03-02 10:28:41 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)