文章目录
- .net framwork4.6操作MySQL报错Character set ‘utf8mb3‘ is not supported 解决方法
- 详细报错内容
- 解决方案
- 修改数据
- 修改表
- 修改字段
.net framwork4.6操作MySQL报错Character set ‘utf8mb3‘ is not supported 解决方法
详细报错内容
System.NotSupportedExceptionHResult=0x80131515Message=Character set 'utf8mb3' is not supported by .Net Framework.Source=MySql.DataStackTrace:在 MySql.Data.MySqlClient.CharSetMap.GetCharacterSet(DBVersion version, String charSetName)在 MySql.Data.MySqlClient.MySqlField.SetFieldEncoding()在 MySql.Data.MySqlClient.NativeDriver.GetColumnData(MySqlField field)在 MySql.Data.MySqlClient.NativeDriver.GetColumnsData(MySqlField[] columns)在 MySql.Data.MySqlClient.Driver.GetColumns(Int32 count)在 MySql.Data.MySqlClient.ResultSet.LoadColumns(Int32 numCols)在 MySql.Data.MySqlClient.ResultSet..ctor(Driver d, Int32 statementId, Int32 numCols)在 MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)在 MySql.Data.MySqlClient.MySqlDataReader.NextResult()在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)在 MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)在 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)在 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)在 System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)在 System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)在 ConsoleAppSQL.Program.GetMySqlDataTable(String mySqlConn, String sql, MySqlParameter[] parms) 在 C:\Users\Administrator\source\repos\ConsoleAppSQL\ConsoleAppSQL\Program.cs 中: 第 27 行在 ConsoleAppSQL.Program.Main(String[] args) 在 C:\Users\Administrator\source\repos\ConsoleAppSQL\ConsoleAppSQL\Program.cs 中: 第 15 行
解决方案
修改字符集和排序为utf8mb4
修改数据
ALTER DATABASEmyblogCHARACTER SET = utf8mb4COLLATE = utf8mb4_unicode_ci;
修改表
ALTER TABLEmm_t_userCONVERT TO CHARACTER SET utf8mb4COLLATE utf8mb4_unicode_ci;
修改字段
alter table mm_t_user modify content VARCHAR(500) character set utf8mb4 COLLATE utf8mb4_unicode_ci;