mysql因版本问题造成报错的处理

查看mysql版本号:cmd中输入mysql -uroot -p,然后输入密码

8.0.##版本的mysql使用低版本的MySql.Data.dll,连接数据库时会报错:Authentication method 'caching_sha2_password' not supported by any of the available plugins.

解决方式:(两种),第一种需要重启mysql服务,第二种不需要重启服务

第一种:

mysql文件中增加my.ini文件,内容如下,关键时最后一行:default_authentication_plugin=mysql_native_password

 

 

然后修改mysql的配置文件路径:

打开cmd,进入命令行,输入:mysqld  --defaults-file="D:\soft\mysql-8.0.23-winx64\my.ini"
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_bin
init_connect='SET NAMES utf8mb4'
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = D:\\soft\mysql-8.0.23-winx64
datadir = D:\\soft\mysql-8.0.23-winx64\data
port = 3306
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 16M
read_rnd_buffer_size = 16M 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
default_authentication_plugin=mysql_native_password

然后重启mysql服务:

net stop mysql

net start mysql

第二种

更换高版本的MySql.Data.dll文件

地址:https://files.cnblogs.com/files/blogs/667310/MySql.Data.rar

不需要重启mysql服务

 

posted @ 2021-12-14 11:20  lingmin210  阅读(596)  评论(0编辑  收藏  举报