centos 7 下 yum 安装 mysql 5.7.29

1、下载 MySQL官方的 yum Repository

[root@iZbp19ftqv2b7y3oba2i6tZ ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

在这里插入图片描述

2、安装 yum 源

[root@iZbp19ftqv2b7y3oba2i6tZ ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm

在这里插入图片描述

3、开始安装MySQL服务器

[root@iZbp19ftqv2b7y3oba2i6tZ ~]# yum -y install mysql-community-server

在这里插入图片描述
如果出现如下错误(centos7.8以上版本):

[root@iZbp19ftqv2b7y3oba2i6tZ ~]# yum -y install mysql-community-server
MySQL Connectors Community                                         124 kB/s |  79 kB     00:00    
MySQL Tools Community                                              482 kB/s | 476 kB     00:00    
MySQL 5.7 Community Server                                         1.5 MB/s | 1.9 MB     00:01    
All matches were filtered out by modular filtering for argument: mysql-community-server
Error: Unable to find a match: mysql-community-server

解决:
先执行:yum module disable mysql
再执行:yum -y install mysql-community-server

4、配置mysql数据库

启动 mysql 服务

[root@iZbp19ftqv2b7y3oba2i6tZ ~]# systemctl start mysqld

查看初始密码

[root@iZbp19ftqv2b7y3oba2i6tZ ~]# grep "password" /var/log/mysqld.log

登录进入数据库,使用上边的密码

[root@iZbp19ftqv2b7y3oba2i6tZ ~]# mysql -uroot -p

如果无法登录,如下报错:

[root@iZbp19ftqv2b7y3oba2i6tZ ~]# mysql -uroot -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

解决方案:
在 /etc/my.cnf 的 [mysqld] 的最后一行加上“skip-grant-tables”用来跳过密码验证的过程
如下:
在这里插入图片描述

//重启mysql
[root@iZbp19ftqv2b7y3oba2i6tZ ~]# service mysqld restart

直接enter进入mysql

[root@iZbp19ftqv2b7y3oba2i6tZ ~]# mysql -uroot -p
Enter password:
mysql> UPDATE mysql.user SET authentication_string=PASSWORD('root') where USER='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit

执行上边的报错则执行UPDATE mysql.user SET Password=PASSWORD(‘root’) where USER=‘root’;试一下

更改密码校验强度

mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;

设置新密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

配置root账号可远程连接

mysql> use mysql;
mysql> select  host,user  FROM user WHERE user='root';
mysql> update user set host= '%'  WHERE user ='root';
mysql> flush privileges;

修改/etc/my.cnf,在[mysqld]下添加如下

#表名不区分大小写(linux默认区分大小写)
lower_case_table_names=0


注:安装了Yum Repository,以后每次yum操作都会自动更新,需要把这个卸载掉

[root@iZbp19ftqv2b7y3oba2i6tZ ~]# yum -y remove mysql57-community-release-el7-10.noarch


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值