question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'

See original GitHub issue

Getting the title error on my linux machine. Works great with the windows test-server on the same database (cloned) and the same code.

I am using utf8mb4_general_ci as standard collation, but utf8mb4_bin at column “token”. I think the part (`lime`.`user`.`token` = ? COLLATE utf8_bin) should use utf8mb4_bin instead? Interestingly enough: It does not help when I convert the column token to utf8_bin!

Stacktrace

2017-06-08T18:10:42.336Z INFO  [http-nio-8080-exec-1] (#APPLICATION_BUILDER) - Speedment (Open Source) version 3.0.10 by Speedment, Inc. Specification version 3.0
2017-06-08T18:10:42.336Z INFO  [http-nio-8080-exec-1] (#APPLICATION_BUILDER) - Java Platform API Specification 1.8 by Oracle Corporation. Implementation N/A 1.8.0_131 by N/A
2017-06-08T18:10:42.655Z INFO  [http-nio-8080-exec-1] (#APPLICATION_BUILDER) - MySQL, 10.0.29-MariaDB-0ubuntu0.16.10.1, MariaDB connector/J 2.0.2, JDBC version 4.2
2017-06-08T18:10:42.852Z ERROR [http-nio-8080-exec-3] (c.s.r.c.i.d.AsynchronousQueryResultImpl) - Error executing SELECT `id`,`token`,`firebase`,`initial`,`timestamp_location`,`distance`,`longitude`,`latitude` FROM `lime`.`user` WHERE (`lime`.`user`.`token`  = ? COLLATE utf8_bin), values=[sometoken]
java.sql.SQLSyntaxErrorException: (conn:18774) COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:158)
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:118)
	at org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:245)
	at org.mariadb.jdbc.MariaDbPreparedStatementClient.executeInternal(MariaDbPreparedStatementClient.java:218)
	at org.mariadb.jdbc.MariaDbPreparedStatementClient.execute(MariaDbPreparedStatementClient.java:153)
	at org.mariadb.jdbc.MariaDbPreparedStatementClient.executeQuery(MariaDbPreparedStatementClient.java:167)
	at com.speedment.runtime.core.internal.db.AsynchronousQueryResultImpl.stream(AsynchronousQueryResultImpl.java:95)
	at com.speedment.runtime.core.internal.component.sql.SqlStreamSupplierImpl.lambda$stream$6(SqlStreamSupplierImpl.java:184)
	at com.speedment.runtime.core.internal.stream.builder.pipeline.PipelineImpl.getStream(PipelineImpl.java:85)
	at com.speedment.runtime.core.internal.stream.builder.pipeline.PipelineImpl.getAsReferenceStream(PipelineImpl.java:63)
	at com.speedment.runtime.core.internal.component.sql.override.def.reference.DefaultFindAnyTerminator.apply(DefaultFindAnyTerminator.java:45)
	at com.speedment.runtime.core.internal.manager.sql.SqlStreamTerminator.findAny(SqlStreamTerminator.java:176)
	at com.speedment.runtime.core.internal.stream.builder.ReferenceStreamBuilder.lambda$findAny$16(ReferenceStreamBuilder.java:406)
	at com.speedment.runtime.core.internal.stream.builder.AbstractStreamBuilder.finallyCloseReference(AbstractStreamBuilder.java:189)
	at com.speedment.runtime.core.internal.stream.builder.ReferenceStreamBuilder.findAny(ReferenceStreamBuilder.java:406)

Database

image

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
fabluecommented, Jun 10, 2017

Fixed by adding the following to my.ini

character-set-server  = utf8mb4
collation-server      = utf8mb4_general_ci

1reaction
minborgcommented, Jun 8, 2017

Komisch, nicht wahr? It might be the case that there are different defaults for the table collation on the two platforms. Try to re-create your table using “utf8” . We do our integration tests on Linux and here is one example of a table created for MariaDB:

CREATE TABLE `user` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  `surname` varchar(45) NOT NULL,
  `email` varchar(45) NOT NULL,
  `password` varchar(45) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `Index_email` (`email`),
  KEY `Index_name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8;
Read more comments on GitHub >

github_iconTop Results From Across the Web

COLLATION 'utf8_bin' is not valid for CHARACTER SET ...
Collations are specific to a character set. If your character set is utf8mb4, then you could use collation utf8mb4_bin but not utf8_bin.
Read more >
Error reading from database - COLLATION 'utf8mb4_bin' is not ...
Error reading from database - COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'utf8' SELECT * FROM mdl_user WHERE LOWER(username) COLLATE utf8mb4_bin .....
Read more >
Collation is not valid for character set - Moodle Wiki
COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'. It means you need to fix the collation on your database tables (MySQL/MariaDB).
Read more >
[Sentinel] SQL Error COLLATION 'utf8_bin' is not valid for ...
[Sentinel] SQL Error COLLATION 'utf8_bin' is not valid for CHARACTER SET 'latin1' when accessing a report in Web-monitoring.
Read more >
COLLATION utf8_unicode_ci is not valid for CHARACTER ...
This error shows up if you have different character and collation setting in your mysql server than what you are trying to source...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found