All we need is an easy explanation of the problem, so here it is.
PostgreSQL
: 9.4
FreeBSD
: 11.2
When I set my TimeZone
parameter in postgresql.conf
to localtime
I receive the following error when trying to start PostgreSQL.
service postgresql restart
<2022-06-02 11:18:27.612 EDT> LOG: invalid value for parameter "TimeZone": "localtime"
<2022-06-02 11:18:27.613 EDT> FATAL: configuration file "/usr/local/pgsql/data/postgresql.conf" contains errors
pg_ctl: could not start server
Examine the log output.
During my searches I’ve found this correspondence which seems to indicate that /etc/localtime should be a symlink. Mine isn’t so I tried changing it to a symlink and it still didn’t work as I get the same error as above.
mv /etc/localtime /etc/localtime.bak
ln -s /usr/share/zoneinfo/America/Yellowknife
shutdown -r now
ls -la /etc/localtime
lrwxr-xr-x 1 root wheel 35 Jun 2 11:04 /etc/localtime -> /usr/share/zoneinfo/America/Yellowknife
Is it possible to get TimeZone
set to localtime
working on FreeBSD
?
Note that I also found this discussion where it mentions creating a symlink
to /etc/localtime
in /usr/share/zoneinfo
. I tried that as well and it did not work as I still get the same error as above.
Using pg_config --configure
I see that it was not configured with --with-system-tzdata
. Is this a requirement to using localtime
?
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
Method 1
The way you configured PostgreSQL, it does not use the operating system’s time zone database, but its own copy, which is located in pg_config --sharedir
. So your symbolic link has no effect.
You’d have to create that symbolic link in PostgreSQL’s copy of the timezone database, but the correct solution is different: set timezone
to America/Yellowknife
.
Do not use unsupported PostgreSQL versions.
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0