How to change timezone in my.cnf keeping daylight savings in consideration

432 views Asked by At

How do we set timezone in my.cnf in mysql?

I tried to set UK's timezone to my mysql server like this:

[mysqld]
default-time-zone= "Europe/London"

I can't even restart mysql when I add this line so this seems to be wrong for some reason. I tried to set it using mysql client and I am getting this error.

enter image description here

if I set it to GMT, would it work fine in the case of daylight savings?

1

There are 1 answers

1
Alan On

Took me ages to find this as I thought timezone tables would be default populated - so hopefully this helps someone else You can do it using the line you have Danyal BUT you have to load the timezone info into mysql first So on the server run this as root

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

Then in my.cnf use

[mysqld]
default-time-zone = 'Europe/London'