linux安装mysql

1.wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.31-1.el8.x86_64.rpm-bundle.tar
2.解压 tar -xvf /usr/local/mysql-8.0.31-1.el8.x86_64.rpm-bundle.tar -C /usr/local/mysql_package
3.依次执行:
rpm -ivh mysql-community-common-8.0.31-1.el8.x86_64.rpm

rpm -ivh mysql-community-client-plugins-8.0.31-1.el8.x86_64.rpm

rpm -ivh mysql-community-libs-8.0.31-1.el8.x86_64.rpm

rpm -ivh mysql-community-client-8.0.31-1.el8.x86_64.rpm

rpm -ivh mysql-community-icu-data-files-8.0.31-1.el8.x86_64.rpm

rpm -ivh mysql-community-devel-8.0.31-1.el8.x86_64.rpm
这个很有可能报错
linux安装mysql_第1张图片
解决办法:更新镜像源
执行以下命令:
sed -i ‘s/mirrorlist/#mirrorlist/g’ /etc/yum.repos.d/CentOS-*
sed -i ‘s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g’ /etc/yum.repos.d/CentOS-*
yum makecache
yum update -y

再次安装:
linux安装mysql_第2张图片

rpm -ivh mysql-community-server-8.0.31-1.el8.x86_64.rpm

检查安装包:
在这里插入图片描述

启动mysql以获取初始密码:
在这里插入图片描述
更改数据库密码:

alter user ‘root’@‘localhost’ identified by ‘12345678’;

你可能感兴趣的:(linux,mysql,运维)