java链接mysql255错误,java.sql.SQLException:从连接器8.0.11的服务器收到的未知初始字符集索引“255”...

While establishing the connection to a MySQL database, I'm getting the following error

java.sql.SQLException: Unknown initial character set index '255' received from

server. Initial client character set can be forced via the 'characterEncoding'

property.

Upon googling, I got to know that we need to modify 2 params in my.ini or my.cnf.

I am using MySQL version 8.0.11 and it does not have this file.

Hence I modified these parameters using the SQL commands:

Please note name and duration are column name in the table.

ALTER TABLE courses MODIFY name VARCHAR(50) COLLATE utf8_unicode_ci;

ALTER TABLE courses MODIFY duration VARCHAR(50) COLLATE utf8_unicode_ci;

ALTER TABLE courses MODIFY name VARCHAR(50) CHARACTER SET utf8;

ALTER TABLE courses MODIFY duration VARCHAR(50) CHARACTER SET utf8;

Hence my table looks like this

5Ikcy.jpg

After this, I restarted MySQL server, but I'm still getting the above error.

Please note I'm deploying my application in tomcat and running rest API call which will connect to the database. While connecting to the database, I'm getting the above error.

解决方案

Using MySQLWorkbench interface:

First click in your connection ->

sDeZS.png

After click in Options File

Bi059.png

And change character-set-server and collation-server values to the values below:

9g6m9.png

Make sure to restart mysql server by opening services and restarting mysql server.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值