centos7安装mysql8.0的rpm版本

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

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

[root@localhost mysql]# wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
--2021-08-07 10:19:52--  https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 104.69.173.148
正在连接 repo.mysql.com (repo.mysql.com)|104.69.173.148|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:26024 (25K) [application/x-redhat-package-manager]
正在保存至: “mysql80-community-release-el7-3.noarch.rpm”

100%[=======================================================================================>] 26,024      --.-K/s 用时 0.05s   

2021-08-07 10:19:53 (504 KB/s) - 已保存 “mysql80-community-release-el7-3.noarch.rpm” [26024/26024])

[root@localhost mysql]# yum -y localinstall mysql80-community-release-el7-3.noarch.rpm
已加载插件:fastestmirror
正在检查 mysql80-community-release-el7-3.noarch.rpm: mysql80-community-release-el7-3.noarch
mysql80-community-release-el7-3.noarch.rpm 将被安装
正在解决依赖关系
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
The program yum-complete-transaction is found in the yum-utils package.
--> 正在检查事务
---> 软件包 mysql80-community-release.noarch.0.el7-3 将被 安装
--> 解决依赖关系完成

依赖关系解决

=================================================================================================================================
 Package                             架构             版本               源                                                 大小
=================================================================================================================================
正在安装:
 mysql80-community-release           noarch           el7-3              /mysql80-community-release-el7-3.noarch            31 k

事务概要
=================================================================================================================================
安装  1 软件包

总计:31 k
安装大小:31 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
** 发现 2 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
2:postfix-2.10.1-9.el7.x86_64 有缺少的需求 libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-9.el7.x86_64 有缺少的需求 libmysqlclient.so.18(libmysqlclient_18)(64bit)
  正在安装    : mysql80-community-release-el7-3.noarch                                                                       1/1 
  验证中      : mysql80-community-release-el7-3.noarch                                                                       1/1 

已安装:
  mysql80-community-release.noarch 0:el7-3                                                                                       

完毕!
[root@localhost mysql]# 
2. 安装 rpm -ivh mysql80-community-release-el7-3.noarch.rpm

3. 安装MySql 

yum -y install mysql-server
4.启动mysql 

systemctl start mysqld
5. 开机启动命令:

systemctl enable mysqld
systemctl daemon-reload
6. 查看mysql 状态

service mysqld status

7.查看临时密码 grep "A temporary password" /var/log/mysqld.log
8. 修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyPassword6@';

#注意8位数以上和种类至少大+写+小写+符号+数字

9.修改初始密码为简单密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '^C;
mysql> SHOW VARIABLES LIKE 'validate_password.%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+

7 rows in set (0.00 sec)
1.validate_password.length 是密码的最小长度,默认是8,我们把它改成6

2. validate_password.policy 验证密码的复杂程度,我们把它改成0

3. validate_password.check_user_name 用户名检查,用户名和密码不能相同,我们也把它关掉


mysql> set global validate_password.length=6;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password.check_user_name=off;
Query OK, 0 rows affected (0.00 sec)

mysql> 

开放3306端口

	firewall-cmd --zone=public --list-ports 查看所有打开的端口
	firewall-cmd --zone=public --add-port=3306/tcp --permanent   # 开放3306端口
	firewall-cmd --zone=public --remove-port=3306/tcp --permanent  #关闭3306端口(这里只是演示一下怎么关闭开放的端口)
	firewall-cmd --reload   # 配置立即生效
修改密码为123456

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> mysql -u root -p^C
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> 

10 修改可以使用Navicat 连接

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+------------------------------------------------------+
| Tables_in_mysql                                      |
+------------------------------------------------------+
| columns_priv                                         |
| component                                            |
| db                                                   |
                       |
| user                                                 |
+------------------------------------------------------+
37 rows in set (0.00 sec)

mysql> select host, user, authentication_string, plugin from user;
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| host      | user             | authentication_string                                                  | plugin                |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.session    | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.sys        | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | root             | $A$005$21}ewX4+n4F{1#(g(/VA4vjXP/s3xMY3aPnsAdwYnnPx1xJ6ZBTCumOjIaN8 | caching_sha2_password |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
4 rows in set (0.00 sec)

mysql> update user set host = '%' where user = 'root' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

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

修改 /etc/my.cnf 更换加密规则

11.再次修改密码:

重启mysql 

# service mysqld restart

Navicat 连接MySQL 出现 Authentication plugin 'caching_sha2_password' cannot be loaded
解决办法:

mysql -u root -p

输入密码

修改账户密码加密规则并更新用户密码

   ALTER USER 'root'@'%' IDENTIFIED BY 'A123456789@' PASSWORD EXPIRE NEVER;   #修改加密规则 

   ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY  'A123456789@';   #更新一下用户的密码 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值