Skip to content

How to set the mysql timezone info? #320

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

Closed
Kooooooma opened this issue Aug 24, 2017 · 4 comments
Closed

How to set the mysql timezone info? #320

Kooooooma opened this issue Aug 24, 2017 · 4 comments

Comments

@Kooooooma
Copy link

When i start up the mysql container use the command like this:

docker run -d --rm -e MYSQL_ROOT_PASSWORD=123456 --name mysql mysql:5.6

And when i run the date command in the container, it is the GMT time.

@tianon
Copy link
Member

tianon commented Aug 24, 2017

I'd recommend setting the TZ environment variable to control the timezone:

$ docker run -it --rm mysql:5.7 date
Thu Aug 24 16:46:59 UTC 2017
$ docker run -it --rm -e TZ='America/Los_Angeles' mysql:5.7 date
Thu Aug 24 09:47:08 PDT 2017

(which, according to https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html, the mysqld server will pick up properly as well)

@Kooooooma
Copy link
Author

@tianon Thanks, this can solve my problem.

@hi-mamba
Copy link

hi-mamba commented Feb 25, 2019

you can set it here docker-compose.yml

mysqldb:
   #image: mysql:5.7.21
   build: .
   #container_name: mysql_container
   ports:
     - "3306:3306"
   environment:
     - MYSQL_ROOT_PASSWORD=root
     - TZ=Europe/Sofia

https://stackoverflow.com/questions/49959601/configure-time-zone-to-mysql-docker-container
https://hub.docker.com/r/bitnami/mysql/

@SambathChea
Copy link

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

No branches or pull requests

4 participants