Centos7安装mysql8.0教程

1.背景

centos7安装mysql8.0

2.安装步骤

步骤一:安装准备工作

1.查看是否有安装过mysql
rpm -qa | grep -i mysql
2.删除mysql
yum -y remove MySQL-*
3.把所有出现的目录统统删除
find / -name mysql
4.删除配置文件
rm -rf /etc/my.cnf

步骤二:下载安装包

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

Centos7安装mysql8.0教程

步骤三:安装

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

Centos7安装mysql8.0教程

步骤四:启动-状态查看

// 启动

sudo service mysqld start

// 状态查看

service mysqld status

Centos7安装mysql8.0教程

步骤五:查看临时密码 登录

grep "A temporary password" /var/log/mysqld.log

mysql -uroot -p

Centos7安装mysql8.0教程

步骤六:修改临时密码

mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘Admin123@‘;
Query OK, 0 rows affected (0.44 sec)

步骤七:配置远程访问

1.查看当前用户

select host, user, authentication_string, plugin from user;

2.添加一个用户

CREATE USER ‘root‘@‘%‘ IDENTIFIED BY ‘Admin123@‘;

Centos7安装mysql8.0教程

3.设置权限

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ WITH GRANT OPTION;
Query OK, 0 rows affected (0.14 sec)

步骤九:修改加密方式,避免客户端链接报错

原因是mysql8的加密方式规则不一样,是caching_sha2_password
需要加密方式改成mysql_native_password就行了
语法:ALTER USER ‘[用户名]’@’%’ IDENTIFIED WITH mysql_native_password BY ‘[密码]’;
输入:ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘Admin123@’;
加密方式以及改成了mysql_native_password

mysql> ALTER USER ‘root‘@‘%‘ IDENTIFIED WITH mysql_native_password BY ‘Admin123@‘;
Query OK, 0 rows affected (1.10 sec)

步骤十:刷新配置生效

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

3.链接测试

Centos7安装mysql8.0教程

 链接成功后,该用户支持数据库建立等很多权限1

完美!

Centos7安装mysql8.0教程

上一篇:Eclipse 使用 jdk 11 时 找不到 java.sql 包的解决方法


下一篇:sql WM_CONCAT 用法