mysql 国内yum源_centos7 国内镜像yum安装mysql5.7

我这里是采用纯净的系统,刚装的centos7,而且选择的最小安装所以基本上是什么环境都没有的,然后这篇文章主要针对于小白

检查mysql环境是否已存在

虽然我的是纯净系统,但别人的不能保证,为了避免发生什么问题我们还是先检查下mysql是否已经安装过

[root@localhost ~]# rpm -qa | grep mysql

[root@localhost ~]# rpm -qa |grep mariadb

mariadb-libs-5.5.64-1.el7.x86_64

我这里要卸载mariadb

[root@localhost ~]# yum remove mariadb-libs-5.5.64-1.el7.x86_64

假如你发现类似的就和我一样删除就好了

切换阿里云镜像源

先安装wget

[root@localhost ~]# yum install wget -y

然后下载阿里云yum源配置

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

然后生成缓存

[root@localhost ~]# yum makecache

显视元数据缓存已建立就代表完成了

然后我们更新一下yum

[root@localhost ~]# yum update -y

这可能需要一点时间,耐心等待一下

下载国内的mysql rpm包并安装

先是server包

[root@localhost ~]# wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-server-5.7.25-1.el7.x86_64.rpm

然后是client包

wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-client-5.7.25-1.el7.x86_64.rpm

还有common

[root@localhost ~]# wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-common-5.7.25-1.el7.x86_64.rpm

最后还有一个lib

[root@localhost ~]# wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-libs-5.7.25-1.el7.x86_64.rpm

在此之前我们还要先安装三个依赖环境

net-tools.x86_64,libaio.x86_64,perl.x86_64

我们直接使用yum安装

yum install -y perl.x86_64

yum install -y libaio.x86_64

yum install -y net-tools.x86_64

然后按照顺序安装mysql的依赖

[root@localhost ~]# rpm -ivh mysql-community-common-5.7.25-1.el7.x86_64.rpm

[root@localhost ~]# rpm -ivh mysql-community-libs-5.7.25-1.el7.x86_64.rpm

[root@localhost ~]# rpm -ivh mysql-community-client-5.7.25-1.el7.x86_64.rpm

[root@localhost ~]# rpm -ivh mysql-community-server-5.7.25-1.el7.x86_64.rpm

然后我们重启下mysql服务

[root@localhost ~]# service mysqld.service restart

我们查看下默认密码

[root@localhost etc]# grep 'temporary password' /var/log/mysqld.log

2020-02-11T09:49:32.224110Z 1 [Note] A temporary password is generated for root@localhost: E;#ySHlql0!>

我的密码为 E;#ySHlql0!>

[root@localhost mysql]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 10

Server version: 5.7.25

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

登录成功,接着改下密码和远程连接

修改密码并开启远程连接

修改密码

这里因为mysql的新版本限制了密码复杂度,所以我们需要设置一个稍微复杂的密码

mysql> set password=password('这里输入你想改的密码');

Query OK, 0 rows affected, 1 warning (0.00 sec)

密码需要包含数字和特殊符号,以及大写字母和小写字母

当然你设置完成以后可以就将密码限制关闭后在重新改密码,这里不过多演示

开启远程连接

打开mysql数据库

mysql> use mysql;

修改一条数据使其支持远程连接

mysql> update user set Host = '%' where Host = 'localhost' and User='root';

刷新系统权限相关表

mysql> flush privileges;

我们用navicat测一下

在此之前请确保防火墙开放了3306端口

fcbd6e57f75ae399f443ddb74723a23c.png

我这里直接一次过了

关于开机自启,这种情况下mysql是自动启动的,不需要多余的配置

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值