MySql.Data.dll 因版本问题造成报错的处理

23 篇文章 0 订阅
15 篇文章 0 订阅

NetCore 链接MySQL 报 Character set ‘utf8mb3‘ is not supported by .Net Framework 异常解决_character set utf8mb3_csdn_aspnet的博客-CSDN博客

查看mysql版本号,两种办法:

第一种在数据库中执行查询:SELECT @@version;

第二种使用工具 Navicat:

点击连接节点:

 

在右侧会显示mysql版本:

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

印象中(具体版本记不清了)MySQL数据库版本大于8.0.26使用8.0.1x的MySql.Data.dll就会报上面的异常信息,MySql.Data.dll版本信息如下:

解决方式:(两种),第一种需要重启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

其实相当于降低数据库版本,本机安装了mysql8.0.32版本设置了default_authentication_plugin:

 

然后重启mysql服务:

net stop mysql

net start mysql

但是重启之后还是不能连接:

第二种

更换高版本的MySql.Data.dll文件,由于项目时nuget安装包,所以再项目发布后,将MySql.Data.dll替换为高版本程序可正常运行,其实是将发布后的8.0.15版本的MySql.Data.dll替换为8.0.29版本的MySql.Data.dll,如下:

 替换后访问程序均正常,后续可能将使用MySqlConnector.dll,尽量避免此问题。

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值