Postgres error “invalid value for parameter ”TimeZ

2020-05-18 04:29发布

Jupitor$ bundle exec rake db:create db:migrate
APP_development already exists
rake aborted!
PG::Error: ERROR:  invalid value for parameter "TimeZone": "UTC"
: SET time zone 'UTC'

I keep getting this error when trying to migrate to my postgres database. help would be much appreciated!

15条回答
2楼-- · 2020-05-18 04:47

I had a similar problem after updating time zone information, that is, downloading the IANA database and compiling using zic.

My problem actually began after restarting PostgreSQL. I got invalid value for parameter TimeZone: UTC and restarting again did nothing to solve the problem.

It turns out my time zone information was completely messed up after the update. I had dangling symbolic links in /usr/share/zoneinfo. From a psql console, I got:

mydb=# SELECT * FROM pg_timezone_names;
ERROR:  could not stat "/usr/share/zoneinfo/PRC": No such file or directory

I deleted all such dangling symlinks. After doing this, at least I could get SELECT * FROM pg_timezone_names to work, but still got the same invalid value... error.

What finally solved the problem for me was creating a new symlink:

cd /usr/share/zoneinfo
ln -s Etc/UTC UTC

After this, SET time zone 'UTC' worked correctly.

查看更多
时光不老,我们不散
3楼-- · 2020-05-18 04:49

Based on @MathiasJ's answer, instead of rebooting my entire machine, I ran

brew services restart postgresql@9.6

and my subsequent rake db:create worked perfectly.

查看更多
Deceive 欺骗
4楼-- · 2020-05-18 04:53

Just a quick reference for those that are not using Postgres.app, but that start psql from the command line or through launchctl. You'll need to adjust the following for where you have your Postgres data and log files located at:

pg_ctl stop
pg_ctl start -D /usr/local/pgsql/data/ -l /usr/local/pgsql/log/server.log
查看更多
我欲成王,谁敢阻挡
5楼-- · 2020-05-18 04:57

I don't think I deserve any points for that but rebooting my Postgres.app (which is better than rebooting the whole system) solved it for me. The app doesn't show up on the Dock, you can find it on the navbar at the top of your window. Hope it helps anyway.

查看更多
仙女界的扛把子
6楼-- · 2020-05-18 04:59

Restarting postgresql works.

To restart if you've installed it using homebrew, brew info postgresql will tell you to:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
查看更多
三岁会撩人
7楼-- · 2020-05-18 04:59

In my case restarting the database didn't help. Updating tzdata (apt-get install tzdata) did the trick for me.

查看更多
登录 后发表回答