加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-13 16:55:25 所属栏目:百科 来源:网络整理
导读:我使用PostgreSQL数据库为我的Ruby on Rails应用程序(在Mac OS X 10.9)。 有什么详细的说明如何升级PostgreSQL数据库? 恐怕我会破坏数据库中的数据或弄乱它。 假设您已经使用home-brew安装和升级Postgres,您可以执行以下步骤。 停止当前Postgres服务器: l
我使用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,以确切地了解你在上述步骤中做什么,以减少沮丧。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读