java.sql.SQLException: Unknown initial character set index '255' received from server for connector 8.0.11

后端 未结 14 1746
再見小時候
再見小時候 2021-02-14 22:13

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

java.sql.SQLException: Unknown initial character set index \'255\' receiv         


        
相关标签:
14条回答
  • 2021-02-14 22:38

    Setting the CharacterEnconding, useUnicode options will work

    jdbc:mysql://localhost:3306/dbname?characterEncoding=utf8&useSSL=false&useUnicode=true"

    0 讨论(0)
  • 2021-02-14 22:39

    Use the same version of MySQL as well as mysql-connector. If you are using tomcat then keep the connector in the lib folder of tomcat.

    0 讨论(0)
  • 2021-02-14 22:40

    Add connector dependency jar file in the POM file after a cross-check with your MySql server version 8.0.x add this dependency it was working for me mysqlmysql-connector-java 8.0.11

    0 讨论(0)
  • 2021-02-14 22:45

    I am using springboot,liquibase, mysql

    I got solution: This error occur just because of mysql connector in dependency and mysql server you install not match(in my case i am using lower version mysql connector and latest mysql server). So just change scope of mysql connector to runtime:

    maven

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
    

    gradle

    dependencies {
    //... other dependencies
    runtimeOnly group:'mysql', name:'mysql-connector-java'
    }
    

    Or if problem yet not solve then use same version or nearby version for both mysql server and mysql connector.

    0 讨论(0)
  • 2021-02-14 22:46

    With version 8 the default characterset changed. When you add your character set to the connection URL like ?characterEncoding=latin1 it might work.

    0 讨论(0)
  • 2021-02-14 22:46

    it is because of mysql-connector version , i,e. My-sql install version and dependency version did not match.

    use same version for myS

    0 讨论(0)
提交回复
热议问题