如何将PostgreSQL从9.4版升级到9.5版,而不会丢失数据?

前端之家收集整理的这篇文章主要介绍了如何将PostgreSQL从9.4版升级到9.5版,而不会丢失数据?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用Postgresql数据库为我的Ruby on Rails应用程序(在Mac OS X 10.9)。

有什么详细的说明如何升级Postgresql数据库

恐怕我会破坏数据库中的数据或弄乱它。

假设您已经使用home-brew安装和升级Postgres,您可以执行以下步骤。

>停止当前Postgres服务器:

launchctl unload〜/ Library / LaunchAgents / homebrew.mxcl.postgresql.plist
>初始化一个新的9.5数据库

initdb /usr/local/var/postgres9.5 -E utf8
>运行pg_upgrade:

pg_upgrade -v \
    -d /usr/local/var/postgres \
    -D /usr/local/var/postgres9.5 \
    -b /usr/local/Cellar/postgresql/9.4.5_2/bin/ \
    -B /usr/local/Cellar/postgresql/9.5.0/bin/

>将新数据移动到位:

cd /usr/local/var
mv postgres postgres9.4
mv postgres9.5 postgres

>重新启动Postgres:

launchctl load〜/ Library / LaunchAgents / homebrew.mxcl.postgresql.plist
>检查/usr/local/var/postgres/server.log以获取详细信息,并确保新服务器正常启动。
>最后,重新安装rails pg gem

gem uninstall pg
gem install pg

我建议你花一些时间阅读PostgreSQL documentation,以确切地了解你在上述步骤中做什么,以减少沮丧。

原文链接:https://www.f2er.com/postgresql/193949.html

猜你在找的Postgre SQL相关文章