由于mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password
解决方案:https://blog.csdn.net/qq_41030861/article/details/100012275 见本博客
解决了这个问题之后,本人又遇到如下问题
在搜索无果之下,多次尝试解决,最终发现在连接MySQL的代码中
private string connectStr = "server=localhost;port=3306;database=数据名;user=root;password=密码;charset=utf8";
必须加上编码格式,并且数据库以及表、表中的键所有的编码格式必须统一为utf8