解决mysql 8.0.20版本“this user requires mysql native password authentication”问题

经过查询后得知是MySQL 8的用户密码加密方式导致,MySQL 8 的默认密码加密方式为 :caching_sha2_password

之前常用的低版本的密码加密方式为:mysql_native_password,所以需要把MySQL 8中的用户密码加密方式修改为常用的加密方式:mysql_native_password

直接修改配置文件,在mysql的配置文件中加入如下配置:

default-authentication-plugin=mysql_native_password

改完配置文件后,重启mysql,重新连接数据库成功,可正常操作。

完整的配置文件内容如下:

[root@xxxxxr]$ cat /etc/my.cnf
[mysqld]
default-authentication-plugin=mysql_native_password
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
bind-address=x.x.x.x
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
#socket=/data/mysql/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
##character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true

[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
log-error=/data/mysql/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid
pid-file=/data/mysql/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

 

posted @ 2020-10-20 20:36  天地一体  阅读(2094)  评论(0编辑  收藏  举报