步骤一:更新yum源
进入网址,选择好发行版,这里是CentOS7版本,mysql=8.0:
mysql | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
进入CentOS终端运行代码:
touch /etc/yum.repos.d/mysql-community.repo
vi /etc/yum.repos.d/mysql-community.repo
按 i 键插入以下文本后,Esc,:wq保存退出,此时yum源更新完毕!
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
[mysql-tools-community]
name=MySQL Tools Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
[mysql-8.0-community]
name=MySQL 8.0 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
步骤二:安装数据库:
yum -y install mysql-community-server --nogpgcheck
步骤三:启动MySQL服务:
systemctl start mysqld
查看mysql服务状态:
systemctl status mysqld