2.1 Zabbix5.0: Centos7安装数据库mysql8.0

2.1  Zabbix5.0: Centos7安装数据库mysql8.0

(1.1)配置主机名

hostnamectl set-hostname zh-cjh

(1.2)永久关闭防火墙

vim /etc/selinux/config

systemctl disable firewalld.service

systemctl stop firewalld.service

systemctl status firewalld.service

 

(2.1)安装前检查:

netstat -lntup|grep mysql

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图1)

 

准备工作

1.查看是否有安装过mysql

rpm -qa | grep -i mysql

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图2)

2.删除mysql

yum -y remove MySQL-*

 一般用rpm -e 的命令删除mysql,这样表面上删除了mysql,可是mysql的一些残余程序仍然存在,并且通过第一步的方式也查找不到残余,yum命令比较强大,可以完全删除mysql.(ps:rpm删除后再次安装的时候会提示已经安装了,这就是rpm没删除干净的原因)

3.把所有出现的目录统统删除

find / -name mysql

    查找mysql的一些目录,把所有出现的目录删除,可以使用rm -rf 路径,删除时请注意,一旦删除无法恢复。

4.删除配置文件

rm -rf /etc/my.cnf

5.删除mysql的默认密码

rm -rf /root/.mysql_sercret

    删除mysql的默认密码,如果不删除,以后安装mysql这个sercret中的默认密码不会变,使用其中的默认密码就可能会报类似Access denied for user ‘root@localhost’ (using password:yes)的错误.

五步完成之后,这样mysql就全部删除干净了,若没安装过mysql可忽略以上步骤

 

(2.2)配置Mysql 8.0安装源

sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图3)

安装Mysql 8.0

sudo yum --enablerepo=mysql80-community install mysql-community-server -y

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图4)

看到complet(完毕)就是安装完啦

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图5)

rpm -qa | grep -i mysql

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图6)

启动mysql服务

sudo service mysqld start

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图7)

 netstat -lntup|grep mysql

 

查看mysql服务运行状态

service mysqld status

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图8)

查看mysql root临时密码

安装完mysql之后,会生成一个临时的密码让root用户登录

[root@zh-cjh ~]# grep "A temporary password" /var/log/mysqld.log

2021-06-29T16:00:20.868347Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Lxkja7jqbf<U

[root@zh-cjh ~]#

 

更改临时密码

[root@zh-cjh ~]# grep "A temporary password" /var/log/mysqld.log

2021-06-29T16:00:20.868347Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Lxkja7jqbf<U

[root@zh-cjh ~]#

[root@zh-cjh ~]#

[root@zh-cjh ~]#

[root@zh-cjh ~]#

[root@zh-cjh ~]# mysql -uroot -p

Enter password: 输入查看到的临时密码

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

Your MySQL connection id is 8

Server version: 8.0.25

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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>  alter user 'root'@'localhost' identified by'root';

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 密码复杂度不符合要求。

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图9)

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图10)

输入:mysql -uroot -p

    Enter password:后面输入临时密码

    登录成功

    输入:ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘new password’;

    会提示:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements(密码不符合当前策略)

    方案1: 设置符合策略的密码(大小写字母+数据+符号)

    方案2:密码策略改简单一点(修改密码策略)

以上采用了复杂密码解决了。

 

mysql客户连接报不允许连接的错误,那是因为没开通远程访问的权限

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图11)

mysql -uroot -p

use mysql;

select host, user, authentication_string, plugin from user;

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图12)

use mysql;

alter user 'root'@'%' identified by'密码';

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

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图13)

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

select host, user from user;

use mysql;

select host, user from user;

flush privileges;

 

 

select host, user, authentication_string, plugin from user;

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图14)

客户端连接:

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图15)

client does not support authentication protocol requested by server; consider upgrading MySQL client

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图16)

解决Navicat连接不上MySql服务器报错:Client does not support authentication protocol requested by server; conside

1.问题原因

通过相关问题查阅,发现是由于navicat版本的问题造成连接失败。mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password

mysql> select user,host,plugin from user where user='root';

+------+------+-----------------------+

| user | host | plugin                |

+------+------+-----------------------+

| root | %    | caching_sha2_password |

+------+------+-----------------------+

1 row in set (0.00 sec)

mysql>

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图17)

MySql查看版本号-1

mysql -uroot -p

mysql> select version();

+-----------+

| version() |

+-----------+

| 8.0.25    |

+-----------+

1 row in set (0.00 sec)

mysql>

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图18)

ALTER USER 'root'@'localhost' IDENTIFIED BY '现在的密码' PASSWORD EXPIRE NEVER;

 

update user set host = 'localhost' where user = 'root';

 flush privileges;

select host, user from user;

select user,host,plugin from user where user='root';

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图19)

 ALTER USER 'root'@'localhost' IDENTIFIED BY '密码' PASSWORD EXPIRE NEVER;

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图20)

select user,host,plugin from user where user='root';

ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY '密码';

 flush privileges;

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图21)

select user,host,plugin from user where user='root';

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

flush privileges;

 select user,host,plugin from user where user='root';

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图22)

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图23)

2.1  Zabbix5.0: Centos7安装数据库mysql8.0(图24)

客户端连接mysql还报错

 查看防火墙状态,关闭状态

服务器需要开放3306端口



Zabbix5(列表、list、全)zabbixlist
http://www.zh-cjh.com/wenzhangguilei/722.html
文章归类、所有文章列表、LISTLIST
http://www.zh-cjh.com/wangzhangonggao/2195.html

1、本站资源长期持续更新。
2、本资源基本为原创,部分来源其他付费资源平台或互联网收集,如有侵权请联系及时处理。
3、本站大部分文章的截图来源实验测试环境,请不要在生产环境中随意模仿,以免带来灾难性后果。

转载请保留出处:  www.zh-cjh.com珠海陈坚浩博客 » 2.1 Zabbix5.0: Centos7安装数据库mysql8.0

作者: cjh


手机扫一扫,手机上查看此文章:

一切源于价值!

其他 模板文件不存在: ./template/plugins/comment/pc/index.htm

未雨绸缪、居安思危!

数据安全、有备无患!

注意操作、数据无价!

一切源于价值!