创建mysql repo文件并编辑
[root@redis /etc/yum.repos.d]# vim mysql-community.repo
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el7/ #这个连接决定了可以安装的版本
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
#因为mysql的官方源站是国外网站,国内下载国外的网站速度很慢,好在清华源有mysql的镜像,我们可以通过清华源加速mysql的下载
上面的repo文件只能下载5.7版本的如果要下载其他版本的只需要替换baseurl的连接即可
找到要下载的mysql版本的连接:
1.打开清华源的yum源页面:https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/
2.选择要下载的版本和操作系统的版本
el7表示linux 发行版redhat,因为centos只是去掉了redhat的收费功能,所以这个版本也合适centos7
3.进入选择的版本,复制url地址
把这个url连接替换掉mysql repo文件得到baseurl链接就可以了
下载展示:
原来下载只有20多k下载能达到700多。
下载mysql5.7
yum -y install mysql-community-server
启动mysql
systemctl start mysqld
登录mysql
yum安装的mysql,root会有一个默认密码
awk '/temporary password/{print $NF}' /var/log/mysqld.log
ktvXngyks6=Q
#用获取到的密码登录
mysql -uroot -p ktvXngyks6=Q
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.28
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql>
mysql>