@localhost ~]# bash
[root@mysql ~]#
//关闭防火墙
[root@mysql ~]# setenforce 0
[root@mysql ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
[root@mysql ~]# systemctl disable --now firewalld
//配置yum源
[root@mysql ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@mysql ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
//创建用户
[root@mysql ~]# useradd -rMs /sbin/nologin mysql
//下载依赖包
[root@mysql ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel ncurses-compat-libs
//下载mysql包并解压
[root@mysql ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
[root@mysql ~]# tar xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
//修改包名,更改属主属组
[root@mysql ~]# cd /usr/local/
[root@mysql local]# mv mysql-5.7.38-linux-glibc2.12-x86_64 mysql
[root@mysql local]# chown -R mysql.mysql mysql*
[root@mysql local]# ll -d mysql/
drwxr-xr-x. 9 mysql mysql 129 Oct 11 13:42 mysql/
//配置环境变量
[root@mysql local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@mysql local]# source /etc/profile.d/mysql.sh
//创建头文件
[root@mysql local]# ln -s /usr/local/mysql/include /usr/include/mysql
//添加帮助文档
[root@mysql local]# vim /etc/man_db.conf
MANDATORY_MANPATH /usr/man
MANDATORY_MANPATH /usr/share/man
MANDATORY_MANPATH /usr/local/share/man
MANDATORY_MANPATH /usr/local/mysql/man
//创建库文件
[root@mysql ~]# vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib/
[root@mysql ~]# ldconfig
//创建数据存放路劲
[root@mysql ~]# mkdir -p /opt/data
[root@mysql ~]# chown -R mysql.mysql /opt/data/
[root@mysql ~]# ll -d /opt/data/
drwxr-xr-x. 2 mysql mysql 6 Oct 11 13:48 /opt/data/
//初始化数据库
[root@mysql ~]# mysqld --initialize --user mysql --datadir /opt/data/
2022-10-11T05:49:31.198902Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-10-11T05:49:31.347232Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-10-11T05:49:31.366252Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-10-11T05:49:31.427201Z 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: 7a1816e2-4928-11ed-a649-000c29074265.
2022-10-11T05:49:31.428093Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-10-11T05:49:31.649647Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-10-11T05:49:31.649663Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-10-11T05:49:31.649960Z 0 [Warning] CA certificate ca.pem is self signed.
2022-10-11T05:49:31.695538Z 1 [Note] A temporary password is generated for root@localhost: h.#agi;KB7%t //临时密码
[root@mysql ~]# echo 'h.#agi;KB7%t' > pass
//编写配置文件
[root@mysql ~]# dnf -y remove mariadb*
[root@mysql ~]# vim /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
//编写system控制脚本
[root |