CentOS8 安装mySql5.7.4

更新yum源

cd /etc/yum.repos.d

vim CentOS-Base.repo
vim CentOS-AppStream.repo
vim CentOS-Extras.repo

三个文件分别对应写入以下内容

AppStream:

baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/

Base:

baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/

Extras:

baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/

修改后清空缓存,重建缓存:

yum clean all
yum makecache

更新密钥

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

开始安装

下载

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

安装镜像

yum -y install mysql57-community-release-el7-10.noarch.rpm

安装mysql

yum module disable mysql
yum -y install mysql-community-server

卸载repo

yum -y remove mysql57-community-release-el7-10.noarch

启动并修改密码

systemctl stop mysqld.service
systemctl start mysqld.service
systemctl status mysqld

查看临时密码

grep "password" /var/log/mysqld.log

登录

mysql -uroot -p

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '';

开启远程访问

grant all privileges on *.* to 'root'@'%' identified by '' with grant option;

刷新

flush privileges;

修改库文件后的一系列问题

配置文件中增加socket并指定新的路径

vi /etc/my.cnf

[client]
socket=/mnt/raid10/mysql/mysql.sock

SELinux开启的时候设置新目录的上下文安全

semanage fcontext -a -t mysqld_db_t "/mnt/raid10/mysql(/.*)?"

restorecon -Rv /mnt/raid10/mysql

ls -lZ

chown -R mysql:mysql /mnt/raid10/mysql

文章参考:

https://blog.csdn.net/qq_43012792/article/details/114372697

https://blog.csdn.net/jx_ZhangZhaoxuan/article/details/129139499

https://www.cnblogs.com/kerrycode/p/12460771.html