mysql安装指定可用版本_Centos7使用yum安装指定版本mysql(只要四步)

本文目录

1 下载mysql源安装包

2 安装mysql的yum源

3 安装并配置mysql

软件环境

系统版本:Centos7.5

本文参考MySQL官方教程,想直接看原版英文教程的可以点击前往

1 下载mysql源安装包

进入官网查看适用的包 点击前往查看

5892d6c40bea632f0442973fc28aa1dc.png

选择符合系统的版本下载(我这里选的是 Red Hat Enterprise Linux 7),点击Download按钮后会跳转到要求登录的页面

81b1855827b11c147b4177a15407f4cd.png

这里可以不用理会,直接选择红色框标记的 No thanks, just start my download. 即可拿到下载链接,然后执行下载命令

wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm

2 安装mysql的yum源

执行yum源安装命令

yum localinstall mysql80-community-release-el7-3.noarch.rpm

检查mysql源是否安装成功

yum repolist enabled | grep "mysql.*-community.*"

修改yum源配置,默认安装最高版本,如需安装其他版本,则进行修改。enabled=1则为安装的版本,将需要安装的版本enable改为1,其他改为0。

可以通过修改yum配置文件来配置

vi /etc/yum.repos.d/mysql-community.repo

[mysql80-community]

name=MySQL 8.0 Community Server

baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$basearch/

# 修改这里

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

也可以使用命令切换需要安装的版本

# 等同于enabled=0

yum-config-manager --disable mysql80-community

# 等同于enabled=1

yum-config-manager --enable mysql57-community

3 安装并配置mysql

yum install mysql-community-server -y

启动MySQL服务并设置开机启动

#重载systemctl守护进程

systemctl daemon-reload

#启动MySQL

systemctl start mysqld

#设为开机自启

systemctl enable mysqld

修改root本地登录密码

# 查看mysql临时密码

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

# 使用改密码登录MySQL

mysql -uroot -p

# 登陆后修改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Okmedical168';

修改密码时如果密码组合太简单可能会遇到报错:

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

如果不想用复杂的密码,可以修改密码的验证强度等级,最简单的就是设置 validate_password_policy 的全局参数为 LOW

mysql> set global validate_password_policy=LOW;

设置允许root远程访问

# 使用mysql数据库

mysql> use mysql;

# 更新root对应的host

mysql> update user set host='%' where user='root';

# 刷新

mysql> flush privileges;

#退出

mysql> quit

记录,分享,交流。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值