连接数据库的时候遇到了如下错误
Cause: java.sql.SQLException: Unknown initial character set index ‘255’ received from server. Initia
Unknown initial character set index ‘255’ received from server. Initial client character set can be forced via the ‘characterEncoding’ property.
遇事不要慌,先简单做个翻译
知道是编码的问题,而且是服务器端编码与数据库编码不匹配的问题,所以先查看数据库的字符集
查看数据库字符集
select SCHEMA_NAME,DEFAULT_CHARACTER_SET_NAME,DEFAULT_COLLATION_NAME,SQL_PATH from information_schema.SCHEMATA;
在url中添加字符集说明
jdbc:mysql://localhost:3306/mybatis?characterEncoding=utf8
如果编码是utf8mb4,url后也拼utf8