Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utf8mb4 client collation to my.cnf in containers #2006

Merged
merged 1 commit into from
Dec 25, 2019

Conversation

rfay
Copy link
Member

@rfay rfay commented Dec 17, 2019

The Problem/Issue/Bug:

mysql import-db and mysql are affected by client config which lacks utf8mb4 (defaults to latin1).

How this PR Solves The Problem:

Add client config to set connection to utf8mb4

Manual Testing Instructions:

Example is coming from @RobertLang, who ran into trouble with imported dbs because of this.

Automated Testing Overview:

We need to add a test to the mysql container to make sure that everything works properly, should be easy enough.

Related Issue Link(s):

Release/Deployment notes:

@RobertLang
Copy link

Please check this very basic project:
dbtest.zip

Steps to reproduce the problem with MySQL 5.7 on macOS Catalina 10.15.1:

ddev start
ddev import-db --src=correct_import.sql
=> check phpMyAdmin
image
(result looks good)

ddev import-db --src=error_import.sql
=> check phpMyAdmin
image
(result is scrambled)

When the sql file doesn't contain the line /*!40101 SET NAMES utf8mb4 */; the import is done using the default connection encoding which is latin1 for the ddev database container.

When checking the db variables with ddev mysql you see that the default character set for client and connection is latin1.

mysql> show variables like "%character%";
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | latin1                     |
| character_set_connection | latin1                     |
| character_set_database   | utf8mb4                    |
| character_set_filesystem | binary                     |
| character_set_results    | latin1                     |
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

I would suggest to make the default connection encoding fit with the default database encoding (which is utf8mb4) to fix this issue.

@rfay rfay marked this pull request as ready for review December 23, 2019 04:37
@rfay
Copy link
Member Author

rfay commented Dec 23, 2019

Thanks for the excellent test. It broke for me with both imports, but with dbimage: drud/ddev-dbserver-mysql-5.7:20191217_utf8mb4_connection (from this PR) in .ddev/config.yaml, it worked fine for me. I'd love it if you'd confirm that behavior, but I think this does it.

I was just using ddev mysql and

mysql> select * from test_table;
+----+---------------------------------------+
| id | testfield                             |
+----+---------------------------------------+
|  1 | Some german umlauts: äöü ß ÄÖÜ        |
|  2 | Some czech text:  Přímé doručení      |
+----+---------------------------------------+
2 rows in set (0.00 sec)

@rfay rfay force-pushed the 20191217_utf8mb4_connection branch from c24fabd to adfa9d0 Compare December 24, 2019 14:00
@rfay rfay merged commit 3391918 into ddev:master Dec 25, 2019
@rfay rfay deleted the 20191217_utf8mb4_connection branch December 25, 2019 04:33
rfay added a commit to rfay/ddev that referenced this pull request Jan 15, 2020
@rfay rfay mentioned this pull request Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants