Centos7 安装 MySQL5.7踩坑实录

Centos7 安装 MySQL5.7踩坑实录


1.使用 wget 获取 rpm

  • wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

  • yum -y install mysql57-community-release-el7-10.noarch.rpm

  • yum -y install mysql-community-server
    这里可能会出现问题,没有 yum, 或者没有 wget,都需要自己预先准备好环境

其次我还遇到了如下问题:
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 的证书过期了,解决方法如下:
执行这个语句: rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

或者 yum install mysql-community-server --nogpgcheck 也行

然后就需要启动并查看状态MySQL:
systemctl start mysqld.service
systemctl status mysqld.service

5.7后mysql的密码设置变得复杂了,如果还想设置 123456,root 这种,需要修改一下配置
首先先查询默认初始化的密码:
grep “password” /var/log/mysqld.log,然后 用 mysql -u root -p 登录;

修改密码:
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘my password’;

最后开启远程访问 (把下面的my passrod替换成自己的密码)

grant all privileges on . to ‘root’@’%’ identified by ‘my password’ with grant option;

flush privileges;

exit

注意防火墙,3306端口啥的需要打开!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值