1.安装相关包
[root@CentOS8 ~]# yum install libaio numactl-libs -y
2.创建用户和用户组
[root@CentOS8 ~]# groupadd mysql
[root@CentOS8 ~]# useradd -r -g mysql -s /bin/false mysql
3.创建存放数据库的文件
[root@CentOS8 ~]# mkdir -p /data/mysql
[root@CentOS8 ~]# chown mysql.mysql /data/mysql
4.下载对应的二进制文件包
网址:https://downloads.mysql.com/archives/community/
[root@CentOS8 ~]# tar -xzf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@CentOS8 ~]# cd /usr/local/
[root@CentOS8 local]# ln -vs mysql-5.7.38-linux-glibc2.12-x86_64/ mysql
[root@CentOS8 local]# chown -R root.root /usr/local/mysql/
5.更改环境变量
[root@CentOS8 ~]# echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@CentOS8 ~]# . /etc/profile.d/mysql.sh
6.准备配置文件
[root@CentOS8 ~]# cat /etc/my.cnf
[mysqld]
datadir=/data/mysql
skip_name_resolve=1
socket=/data/mysql/mysql.sock
log-error=/data/mysql/mysql.log
pid-file=/data/mysql/mysql.pid
[client]
socket=/data/mysql/mysql.sock
7.生成root空密码
mysqld --initialize-insecure --user=mysql --datadir=/data/mysql #初始化mysql数据库的时候会把root密码设置成一个空密码
#初始化生成mysql数据库的相关文件(和mysql5.6的不一样)
8.准备服务脚本和启动
[root@CentOS8 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@CentOS8 ~]# chkconfig --add mysqld
[root@CentOS8 ~]# service mysqld start
9.测试登录
[root@CentOS8 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.38 MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
标签:二进制,安装,mysql5.7,local,data,mysqld,mysql,root,CentOS8
From: https://www.cnblogs.com/heyongshen/p/16665491.html