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.

MySQL DB encoding problem

See original GitHub issue

System information:

  • 4.2.0-35-generic #40~14.04.1-Ubuntu
  • DBeaver ver. 6.3.4.202002011957

Connection specification:

  • MySQL ver. 5.7.19

Describe your question:

Hello,

I have several legacy MySQL databases which are created in latin1 charset but in fact data is stored in UTF8 encoding.

So I have to use “SET NAMES latin1” query each time I connect to these databases, no matter I do it manually or from scripts. After that query everything is alright with encoding.

But in DBeaver I cannot change the encoding using “SET NAMES latin1”.

image

(by the way, MySQL Workbench shows database contents in proper encoding after “SET NAMES latin1” query)

So the question is: may there be any kind of workaround for this situation?

mysql> select @@character_set_client, @@character_set_results, @@character_set_connection;                                                                                                                                                   +------------------------+-------------------------+----------------------------+
| @@character_set_client | @@character_set_results | @@character_set_connection |
+------------------------+-------------------------+----------------------------+
| utf8                   | utf8                    | utf8                       |
+------------------------+-------------------------+----------------------------+
1 row in set (0,00 sec)

mysql> select * from roles limit 3;
+--------+----------+----------------------------------------------------------+
| idrole | rolename | roletitle                                                |
+--------+----------+----------------------------------------------------------+
|      1 | admin    | ÐдминиÑтратор                               |
|      2 | guest    | ГоÑÑ‚ÑŒ                                               |
|      3 | default  | По умолчанию                                  |
+--------+----------+----------------------------------------------------------+
3 rows in set (0,00 sec)

mysql> SET NAMES latin1;
Query OK, 0 rows affected (0,00 sec)

mysql> select * from roles limit 3;
+--------+----------+----------------------------+
| idrole | rolename | roletitle                  |
+--------+----------+----------------------------+
|      1 | admin    | Администратор              |
|      2 | guest    | Гость                      |
|      3 | default  | По умолчанию               |
+--------+----------+----------------------------+
3 rows in set (0,00 sec)

mysql> SHOW CREATE TABLE roles;
| roles | CREATE TABLE `roles` (
  `idrole` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `rolename` varchar(45) NOT NULL,
  `roletitle` varchar(254) NOT NULL,
  PRIMARY KEY (`idrole`),
  UNIQUE KEY `rolename` (`rolename`)
) ENGINE=MyISAM AUTO_INCREMENT=22 DEFAULT CHARSET=utf8 |

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
eloscurocommented, Feb 12, 2020

[Feature request] Warning if “SET NAMES” command with MYSQL. Message will be with url https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-charsets.html Similar mechanism can be in PostgreSQL and Oracle DB.

Well, that might be a good idea, at least it will be less confusing, but it doesn’t solve the problem… 😦

1reaction
fkulakovcommented, Feb 12, 2020

Wow guys, I’m work the same job as you but I haven’t got those problem because I’m use DataGrip

Read more comments on GitHub >

github_iconTop Results From Across the Web

Character encoding issues in MySQL - Stack Overflow
1 Answer 1 ... Your mySQL data is most likely UTF-8 encoded. ... You need to either specify the correct character set when...
Read more >
Debugging Character Set Issues by Example - MySQL
Before you start migrating your data to MySQL 8.0 and Unicode, be sure that your environment and your client agree on the character...
Read more >
Why is there a MySQL character encoding issue after ...
I believe there is some character encoding issue at this point. Just in case it wasn't a bad export I imported it locally...
Read more >
How to Fix the Collation and Character Set of a MySQL ...
1. Stop Confluence · 2. Edit the <local-home>/confluence.cfg.xml file · 3. Update the following line to add the connectionCollation=utf8mb4_bin parameter to your ...
Read more >
MySql encoding problem - can't change to utf-8 - SitePoint
You indicate that the database is set up properly with the database collation and text fields set to utf8_general_ci. And since you can...
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