篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL:Unknown character set:utf8mb4怎么解决相关的知识,希望对你有一定的参考价值。
参考技术A
Unknown character set: 'utf8mb4' 这是数据库报的错吧把你的mysql-connector-java的jar包。
Unknown character set: 'utf8mb4'
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown character set: 'utf8mb4'at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
atorg.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:382)
atorg.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:456)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:464)
atorg.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:472)
atorg.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:477)
atorg.springframework.jdbc.core.JdbcTemplate.queryForInt(JdbcTemplate.java:486)
1、修改my.cnf后,执行 service mysql restart 重启数据库失败
service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL... ERROR! The server quit without updating PID file (/usr/local/mysql/data/VM_0_12_centos.pid)
2、查看日志:
cat VM_0_12_centos.err |grep ERROR
2018-02-27 22:33:50 923 [ERROR] /usr/local/mysql/bin/mysqld: unknown variable ‘default-character-set=utf8‘
2018-02-27 22:33:50 923 [ERROR] Aborting
3、很明显是没有default-character-set这个变量
4、查了下资料得知 character_set_server来取代 default-character-set
5、修改my.cnf。将default-character-set=utf8 换成character_set_server=utf8。重启数据库,启动成功。