centos6.8 使用yum安装 mysql5.7

发布时间 2023-12-12 10:58:50作者: 505donkey

配置系统yum源

这一步可选,如果yum源使用正常可跳过,由于centos6支持已于2020年停止,安全维护也只支持到2024年11月30日,所以很多原来可用的yum源也失效了,试了几个后找到以下可用的。

  1. 备份旧配置
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. 下载仓库配置文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos6_base.repo

image

  1. 更新本地缓存
yum clean all

image

yum makecache

image

下载mysql安装包

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

image

安装yum源配置包

安装用来配置mysql的yum源的rpm包。

  1. 使用rpm方式
rpm -Uvh mysql57-community-release-el6-9.noarch.rpm
  1. 使用yum方式
yum localinstall -y mysql57-community-release-el6-9.noarch.rpm

image

验证yum源的rpm包是否安装成功。

ls /etc/yum.repos.d/

image

安装mysql

yum -y install mysql-community-server

image

开启mysql服务

service mysqld start

image

查看默认生成密码

grep 'temporary password' /var/log/mysqld.log

image

登录mysql

获取上一步拿到的初始登录密码,输入后完成登录。

mysql -uroot -p

image

修改初始密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '你的新密码';

image
【注意】新密码需要满足 字母大小写+数字+特殊符号 的密码策略,否则会提示 "ERROR 1819 (HY000): Your password does not satisfy the current policy requirements" 错误。