CentOS安装配置MySQL详细教程
一、卸载系统中自带的MariaDB
# 检查MariaDB
rpm -qa | grep mariadb
# 卸载MariaDB
rpm -e --nodeps mariadb-libs
二、下载MySQL安装包
- 下载地址https://downloads.mysql.com/archives/community/
三、将MySQL压缩包上传至/opt目录
四、解压MySQL安装包
tar -xvf mysql-8.0.35-1.el7.x86_64.rpm-bundle.tar
五、按如下顺序安装RPM包
rpm -ivh mysql-community-common-8.0.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.35-1.el7.x86_64.rpm
六、对MySQL进行初始化
mysqld --initialize --console
七、修改MySQL安装目录的所属用户和所属组(方便权限管理)
chown -R mysql:mysql /var/lib/mysql/
八、查看MySQL的临时密码
cat /var/log/mysqld.log | grep localhost
九、检查MySQL运行状态,若运行异常,则重启MySQL
# 检查MySQL运行状态
systemctl status mysqld
# 若运行异常,则重启MySQL
systemctl restart mysqld
十、登录MySQL,并修改密码
# 登录
mysql -uroot -p
# 修改密码
alter user 'root'@'localhost' identified by '123456';
标签:8.0,教程,CentOS,MySQL,community,64,mysql,rpm
From: https://www.cnblogs.com/Natsunobourei/p/18009899