-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Using option --default-time-zone
at first run makes mysql_install_db
script fail
#543
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
Comments
As a work around you could use a string indicating an offset from UTC, such as '+10:00' or '-6:00'. Changing the variable to $ env TZ=Europe/Paris date
Tue Feb 26 19:07:08 CET 2019
$ docker exec -it mysql-543_mysql_1_d66a05665422 mysql -pxxxyyy
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.62 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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 LOCALTIME() FROM DUAL;
+---------------------+
| LOCALTIME() |
+---------------------+
| 2019-02-26 19:07:35 |
+---------------------+
1 row in set (0.00 sec) Reference docs https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html |
@wglambert this workaround will fail every time when the country is switching between winter and summer time. |
@wglambert Thanks for the reply 😉 But I have to agree with @Andor, this workaround is not reliable because of the winter/summer time we use in some european countries (which is the case in France for example) |
@yannoff I just created my own workaround/hack:
Not tested yet, but should works. |
Ok, it doesn't work so I put another hack:
and
And it finally works:
|
@Andor Thanks for your contribution, I appreciate 😺 Actually I have already found a much simpler workaround myself, which proved to work very well, by setting the Here is the #docker-compose.yml
version: '3'
services:
mysql:
image: mysql:5.5
environment:
MYSQL_DATABASE: acme
MYSQL_ROOT_PASSWORD: xxxyyy
# Set timezone as a global env var so that MySQL server starts with the right tz
TZ: Europe/Paris
command:
- mysqld
- "--character-set-server=utf8mb4"
- "--skip-character-set-client-handshake"
- "--collation-server=utf8mb4_unicode_ci" The problem of your solution (as well as mine) is that they are, as you said, hacks. Plus, I think the |
I have a patch to
All it does is overrides the default time zone when initialising the database, by changing the instances of: "$@" --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }'
"$@" --initialize-insecure
"$@" --skip-networking & to: "$@" --default-time-zone=SYSTEM --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }'
"$@" --default-time-zone=SYSTEM --initialize-insecure
"$@" --default-time-zone=SYSTEM --skip-networking & but leaves the actual final This works for me, while allowing the user to specify Hope this helps, |
Closing given the rationale in #544 (comment), namely:
|
I've come up with a solution that overrides entrypoint with code that that extracts I think this is a more fragile solution than just fix the entry point to use echo 'Initializing database'
- "$@" --initialize-insecure --skip-ssl
+ "$@" --initialize-insecure --skip-ssl --default-time-zone=SYSTEM
echo 'Database initialized' Given that EDIT: I'll try to make PR later, given the arguments above and the simplicity of the fix. Seeing how wild are the hacks around the problem makes me cry. |
@glensc That's an interesting - and much welcome - new approach to address the problem... Sounds great 🎉 👍 |
Started the PR: It needs testing all versions and moving the changes to template files. |
When using option
--default-time-zone
in docker command, the MySQL initialization script fails, because the timezone tables haven't been populated yet whenmysql_install_db
is invoked.Here is an example, using the following
docker-compose
configuration:And here is the resulting log:
I think this might have been introduced by #358
The text was updated successfully, but these errors were encountered: