Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown initial character set index '255' received from server

Some further investigation showed that the issue was exactly in changes which were done in MySQL v.8.0:

Character Set Support

Important Change: The default character set has changed from latin1 to utf8mb4. These system variables are affected:

The default value of the character_set_server and character_set_database system variables has changed from latin1 to utf8mb4.

The default value of the collation_server and collation_database system variables has changed from latin1_swedish_ci to utf8mb4_0900_ai_ci.

All these change were already processed in new version of mysql-connector-java and there is no need to configure your MySQL. So change from 5.1.6 to 5.1.44 fix the issue:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.44</version>
</dependency>

User below URL, It works for me.

url=jdbc:mysql://localhost:3306/hybrisdb?characterEncoding=latin1&useConfigs=maxPerformance

This Works for me!

 <property name="JDBC.ConnectionURL"  value="jdbc:mysql://localhost:3306/empdemo?characterEncoding=utf8"></property>

This below change worked to me

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.44</version>
    </dependency>

for this connection

    @Bean
@Profile("dev")
public DataSource dataSourceDev() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setUsername("root");
    dataSource.setPassword("password");
    dataSource.setUrl("jdbc:mysql://localhost:3306/<yourdatabasehere>");
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    return dataSource;
}

This works for me and you can try this too :)

url="jdbc:mysql://localhost:3306/dbname?characterEncoding=utf8"

Was facing the same issue.. So I updated the connector version(8.0.18) and it was resolved.


What helped for me was appending this to my URL:

useUnicode=true&character_set_server=utf8mb4&useLegacyDatetimeCode=false

This completely fixed the issue.