1.背景
背景請參考:【MySQL】MySQL 8 IDEA連接本地MySQL報錯 Host DESKTOP-MISSMJIJ is not allowed to connect to this serv
根據上述操作後報錯
Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property.
這是因爲連接的方式不對
String url = "jdbc:mysql://localhost:3306/db_cjky?useUnicode=true&characterEncoding=utf8";//改成這句,就可以了
改成上述就可以了