[root@localhost ~]# useradd -r -M -s /sbin/nologin mysql //创建用户
[root@localhost ~]# cd /usr/src/
[root@localhost src]# tar -xf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local/ //解压软件包、
[root@localhost src]# cd /usr/local/
[root@localhost local]# mv mysql-5.7.37-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# chown -R mysql.mysql mysql/ //修改权限
[root@localhost local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost local]# source /etc/profile.d/mysql.sh
[root@localhost local]# which mysql
/usr/local/mysql/bin/mysql //配置环境变量
[root@localhost mysql]# ln -s /usr/local/mysql/include/ /usr/include/mysql //配置include软连接
[root@localhost mysql]# vim /etc/ld.so.conf.d/mysql.conf
[root@localhost mysql]# cat /etc/ld.so.conf.d/mysql.conf //配置lib库
/usr/local/mysql/lib
[root@localhost mysql]# vim /etc/man_db.conf //添加man文档
MANDATORY_MANPATH /usr/local/mysql/man
#创建数据库目录
[root@localhost ~]# mkdir -p /opt/data/{3306,3307,3308}
[root@localhost ~]# chown -R mysql.mysql /opt/data/
[root@localhost ~]# cd /opt/data/
[root@localhost data]# ll
总用量 0
drwxr-xr-x. 2 mysql mysql 6 7月 2 11:37 3306
drwxr-xr-x. 2 mysql mysql 6 7月 2 11:37 3307
drwxr-xr-x. 2 mysql mysql 6 7月 2 11:37 3308
配置多实例部署
3306初始化
[root@localhost ~]# mysqld --initialize --user=mysql --datadir=/opt/data/3306
2022-07-02T00:39:07.431121Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-02T00:39:07.703358Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-02T00:39:07.831924Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-02T00:39:07.952119Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 8737c75c-f9b8-11ec-a29d-000c29d84f4a.
2022-07-02T00:39:07