JDBC连接错误(Illegal mix of collations。。。)
1、连接java和mysql时出现了这样的报错:
java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,IMPLICIT)
and (utf8_general_ci,COERCIBLE) for operation '='
解决方法:在mysql命令下执行:ALTER DATABASE mybatisdb DEFAULT CHARACTER SET utf8 COLLATE utf8_bin
,然后重新建表就可以了。
2、java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
解决方法:grant all privileges on *.* to 'root'@'127.0.0.1' identified by '密码'; 然后flush privileges;