linux centos7下安装mysql5.7

首先yum安装方式比较方便,压缩包太麻烦了
1.首先需要安装mysql的yum源
[root@localhost ~]# yum install http://repo.mysql.com/mysql57-community-release-el7.rpm

2.检查老版本或者是文件是否存在,如有删除。
[root@localhost ~]# rpm -qa | egrep mariadb|mysql #查看是系统否存在老版本的mysql(mariadb)
mariadb-5.5.56-2.el7.x86_64
mariadb-libs-5.5.56-2.el7.x86_64

[root@localhost ~]# rpm -e mariadb* --nodeps

3.检查mysql组和用户是否存在,如无创建。
[root@localhost ~]# yum clean all #清空一下yum的缓存
[root@localhost ~]# yum install mysql-server -y #开始安装mysql

4.然后就是开启mysqld服务,service mysqld start
5.初始密码在哪看我忘了,也没搜到,所以直接修改my.cnf
设置免密登录
vim /etc/my.cnf
在[mysqld]下加一句skip-grant-tables
在这里插入图片描述
6.接着重启mysqld服务
systemctl restart mysqld
然后就可以免密登录mysql了
7.mysql -uroot -p 回车,密码直接不用输按回车进入

在这里插入图片描述
8.因为5.7版本的user表中密码字段是authentication_string
update mysql.user set authentication_string=password(‘123’)where user=‘root’;
9.接着退出mysql,把skip-grant-tables注释掉,再保存并重启mysqd
systemctl restart mysqld
10.这次就可以用密码登录mysql了
但是第一次使用系统依然要求修改密码
可以按照他的提示修改
alter user ‘root’@‘localhost’ identified by ‘123’;
11.然而提示密码过于简单,所以需要修改安全等级
set global validate_password_policy=0;
set global validate_password_length=0;
然后继续alter user ‘root’@‘localhost’ identified by ‘123’;就好了
12.试一试可以用了
13.继续,添加远程访问权限
grant all privileges on . to root@’%’ identified by “password”;
flush privileges;
这样就可以远程访问数据库了

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值