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 encoding hints for mysql, mariadb, and percona #502

Merged
merged 1 commit into from
Mar 14, 2016

Conversation

yosifkit
Copy link
Member

Needs docker-library/mysql#147, docker-library/percona#15, MariaDB/mariadb-docker#45 for end user clarity when using --help.

$ # new:
$ docker run -it --rm maridb --help
mysqld  Ver 10.1.11-MariaDB-1~jessie for debian-linux-gnu on x86_64 (mariadb.org binary distribution)
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Starts the MariaDB database server.

Usage: mysqld [OPTIONS]

For more help options (several pages), use mysqld --verbose --help.
$ # old, one of the password options is required to get anywhere
$ docker run -it --rm -e MYSQL_ALLOW_EMPTY_PASSWORD=1 mariadb --help
...# tons of output creating the initial database

Database initialized
MySQL init process in progress...
mysqld  Ver 10.1.11-MariaDB-1~jessie for debian-linux-gnu on x86_64 (mariadb.org binary distribution)
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Starts the MariaDB database server.

Usage: mysqld [OPTIONS]

For more help options (several pages), use mysqld --verbose --help.
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process in progress...
MySQL init process failed.

Fixes docker-library/mysql#14
(replaces) Fixes #237

@yosifkit
Copy link
Member Author

Example setting character set and collation for the server:

$ docker run -d --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -e MYSQL_DATABASE=testing mysql --character-set-server=utf8 --collation-server=utf8_unicode_ci
$ docker run -it --link mysql:mysql --rm mysql mysql -hmysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.11 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SELECT schema_name, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA;
+--------------------+----------------------------+------------------------+
| schema_name        | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME |
+--------------------+----------------------------+------------------------+
| information_schema | utf8                       | utf8_general_ci        |
| mysql              | utf8                       | utf8_unicode_ci        |
| performance_schema | utf8                       | utf8_general_ci        |
| sys                | utf8                       | utf8_general_ci        |
| testing            | utf8                       | utf8_unicode_ci        |
+--------------------+----------------------------+------------------------+
5 rows in set (0.00 sec)

mysql> ^DBye

@@ -72,6 +72,20 @@ Note that users on host systems with SELinux enabled may see issues with this. T
$ chcon -Rt svirt_sandbox_file_t /my/custom
```

### Configuration without a `cnf` file

Many configuration options can be passed as flags to `mysqld`. This will give you the flexibility to customize the container without needing a `cnf` file. For example, if you want to change the default encoding and collation for all tables to use `utf8` just run the following:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should change "utf8" to "UTF-8 (utf8mb4)" and update the example below so that we're recommending "real" UTF-8, not the broken 3-byte version 😄

@tianon
Copy link
Member

tianon commented Feb 25, 2016

LGTM otherwise, pending those --help PRs

@yosifkit
Copy link
Member Author

Updated!

@tianon
Copy link
Member

tianon commented Mar 12, 2016

Now waiting on docker-library/official-images#1533 -- once that merges, we're good to go here.

@yosifkit
Copy link
Member Author

docker-library/official-images#1533 merged; will merge once they are built and pushed to the hub.

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