1
0

7.centos7离线安装mysql5.7.md 1.5 KB

[TOC]

1、卸载CentOS7系统自带的mariadb和mysql

# 1.删除mariadb
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs-5.5.64-1.el7.x86_64
# 2.删除mysql
rpm -qa |grep -i mysql
yum remove mysql*
find / -name mysql # 删除相关目录
rm -rf #删除相关目录
rm -rf /etc/my.cnf
rm -rf /var/log/mysqld.log

2、上传安装包,安装mysql

# 1.解压
tar -xvf mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar 
# 2.执行安装
rpm -ivh *.rpm --nodeps --force

3、配置Mysql

# 1.首先启动mysql服务
systemctl start mysqld && systemctl enable mysqld
# 2.查看默认生成的密码
cat /var/log/mysqld.log | grep password
2021-12-07T06:31:15.336280Z 1 [Note] A temporary password is generated for root@localhost: v;pW)YU;S9fr
2021-12-07T06:32:52.501914Z 0 [Note] Shutting down plugin 'sha256_password'
2021-12-07T06:32:52.501916Z 0 [Note] Shutting down plugin 'mysql_native_password'
2021-12-07T06:33:08.907588Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
# 3.使用该密码登录本地 MySQL 服务器 (v;pW)YU;S9fr)
mysql -u root -p
# 4.设置mysql密码
# 设置密码等级
set global validate_password_length=4;
set global validate_password_policy=0;
# 修改默认密码,注意替换后面的密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'r';
flush privileges;
# 5.开放远程连接
use mysql;
update user set user.Host='%' where user.User='root';
flush privileges;
select host,user from user;