centos7.0安装mysql8.0.20

1.下载MySQL8.0.20版本

2.检查Linux是否含有mariadb文件,如果有,则强制删除

        rpm -qa|grep mariadb

        rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

3.解压安装包

        tar xvf mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar

4.安装rpm包,rpm包安装顺序为:

        rpm -ivh common-8.0.20、libs-8.0.20、client-8.0.20、server-8.0.20

5.初始化mysql

        mysqld --initialize --console

6.修改mysql的相关文件属性

        chown -R mysql:mysql /var/lib/mysql/

7.启动mysql服务

        systemctl start mysqld

8.登录mysql数据库之前需要查看mysql设置的默认登录密码

        cat /var/log/mysqld.log |grep password

9.登录mysql

        mysql -uroot -p

        输入密码

10.登录成功,修改数据库密码

        alter user 'root'@'localhost' identified by 'root';

 --通过datagrip连接mysql

        1.首先,直接停掉防火墙

                查看防火墙状态:firewall-cmd --state

                关闭防火墙:systemctl stop firewalld

                禁止防火墙开启自启:systemctl disable firewalld

        2.datagrip测试mysql连接仍然会报错:

                message from server: "Host '192.168.92.1' is not allowed to connect to this MySQL server

        解决办法: 在mysql登录的状态下执行以下命令

                mysql> select user,host from mysql.user;

                mysql> update mysql.user set host='%' where user='root';

                mysql> flush privileges;

你可能感兴趣的:(mysql,linux,服务器)