linux centos自动安装mysql5.7 国内镜像解决下载慢问题

查看linux系统版本:我的是centos7.9。

cat /etc/os-release

1、下载:

wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

2、运行:

rpm -ivh mysql57-community-release-el7-9.noarch.rpm

这时,cd /etc/yum.repos.d/ 目录下回多了两个文件:mysql-community.repo
mysql-community-source.repo,这里只作了解。

3、安装:

yum install mysql-server

这里需要下载文件,如果快则好,直接到第4步。如果很慢,可以ctrl+c先中断安装,手动下载该文件后再安装。
这里有几个国内镜像,先看看有没有你需要的版本:

  • http://mirrors.sohu.com/mysql/MySQL-5.7/
  • http://uni.mirrors.163.com/mysql/Downloads/MySQL-5.7/
  • http://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-5.7-community/el/7/x86_64/

我安装的时候发现最后一个镜像有最新版本5.7.41,复制链接http://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.41-1.el7.x86_64.rpm

进入这个目录:

cd /var/cache/yum/x86_64/7/mysql57-community/packages/

手动下载:

wget http://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.41-1.el7.x86_64.rpm

下载以后继续yum install mysql-server安装。

4、启动、查看状态、添加开机启动

systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld

5、查看初始密码

grep password /var/log/mysqld.log

6、登录mysql、修改密码

mysql -u root -p
alter user root@localhost identified by '新密码';

猜你喜欢

转载自blog.csdn.net/jeesr/article/details/130017010