# 安装步骤
- 下载命令
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
1
- mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
1
- 先尝试安装
yum install -y mysql-community-server
1
如果可以安装那么安装之后查询mysql版本
mysql -V
1
显示5.7版本则安装成功
# 修改安装源5.7为5.6
- 修改mqsql源
# 要安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可
vi /etc/yum.repos.d/mysql-community.repo
1
2
2
配置信息
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=0 #####################################
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1 #######################################
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql-tools-preview]
name=MySQL Tools Preview
baseurl=http://repo.mysql.com/yum/mysql-tools-preview/el/7/$basearch/
enabled=0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 启动mysql服务
systemctl start mysqld
1
# mysql开启启动
systemctl enable mysqld
1
# 查看mysql密码
grep 'temporary password' /var/log/mysqld.log
1
# 修改密码
# 1、设置安全级别
set global validate_password_policy=0;
# 2、默认密码为8,可以设置为其他值,最小4位
set global validate_password_length=4;
# 3、设置root密码
set password for root@localhost = password('新密码');
# 4、mode报错则修改配置文件
sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8