MySQL :: Download MySQL Community Server (Archived Versions)
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
删除默认存在的mariadb-libs
bash
rpm -e mariadb-libs --nodeps
安装mysql
bash
cd /usr/local/src/ && mkdir mysql && cd mysql
bash
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
bash
tar xf mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
bash
mv mysql-5.7.44-linux-glibc2.12-x86_64 /usr/local/mysql/
添加永久环境变量
bash
sed -i '$aexport PATH=$PATH:/usr/local/mysql/bin' /etc/profile
source /etc/profile
创建mysql用户
bash
useradd mysql -l
准备mysql数据库目录
bash
mkdir -p /usr/local/mysql/data
bash
chown -R mysql:mysql /usr/local/mysql
准备mysql配置文件
bash
cat <<jingyu >> /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
pid-file=/usr/local/mysql/data/mysqld.pid
log-error=/usr/local/mysql/data/mysql.err
socket=/tmp/mysql.sock
jingyu
初始化mysql数据库
bash
mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql
之后会在data目录下生成这些文件
复制启动脚本
由于之前做了环境变量可直接复制到/usr/local/mysql/bin下
bash
ln -s /usr/local/mysql/support-files/mysql.server /usr/local/mysql/bin/
启动mysql
bash
mysql.server start
过滤临时密码
临时密码需要启动mysql在后才会有。
bash
grep password /usr/local/mysql/data/mysql.err
bash
mysql -uroot -p
设置用户密码
bash
alter user root@localhost identified by 'CSDN-jingyu1610';