CentOS7安装mysql5.7(yum方式)

  • 查看当前yum仓库是否包含mysql-server相关包
yum whatprovides mysql-server
  • 下载yum仓库文件包
wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm

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

#再次查看
yum whatprovides mysql-server
  • 安装mysql
yum -y install mysql-server

 如果报错:The GPG keys listed for the "MySQL 5.7 Community Server" repository are already             installed but they are not correct for this package.
  Check that the correct key URLs are configured for this repository.
原因:这是由于MySQL GPG 密钥已过期导致的问题,解决出处需要运行命令, 以2022年为例

解决:以2022年为例

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

  • 启动
systemctl start mysqld

#设置开机启动
systemctl enable mysqld

systemctl daemon-reload
  • 修改root密码
vim /var/log/mysqld.log

在这里插入图片描述

记住初始密码:
修改root 密码
 

mysql -u root -p

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root123$%^'; 

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Root123$%^' WITH GRANT OPTION;



exit
  • 配置mysql默认编码为utf-8

vim /etc/my.cnf

# 在文件末尾添加以下信息

character_set_server=utf8

init_connect='SET NAMES utf8'

  • 重启MySQL

systemctl restart mysqld

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值