如何更改PostgreSQL数据目录?

编程入门 行业动态 更新时间:2024-10-22 23:05:13
本文介绍了如何更改PostgreSQL数据目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在Windows7上的postgresql 9.2上更改数据目录时遇到问题:

I am having a problem changing the data directory on postgresql 9.2 on windows7:

我试图更改我的数据目录:

i`m trying to change my data directory:

如何使用pgAdmin更改postgreSQL上的数据目录?

how can i change data directory on postgreSQL with pgAdmin?

推荐答案

在pgAdmin内部无法实现(或任何其他SQL客户端,因为您需要停止Postgres服务器才能移动数据目录)

This not possible from within pgAdmin (or any other SQL client because you need to stop the Postgres server in order to move the data directory)

要移动目录,请执行以下步骤:

To move the directory, use these steps:

  • 停止Postgres(可以使用控制面板找到正确的服务名称)

  • Stop Postgres (you can use the control panel to find the correct service name) net stop <name_of_the_service>

  • 确保Postgres未运行(例如使用ProcessMonitor)
  • 使用以下命令删除Windows服务

  • Make sure Postgres is not running (e.g. using ProcessMonitor)
  • Remove the Windows service using

    pg_ctl unregister -N <name_of_the_service>

  • 确保Postgres未运行
  • 移动数据目录到新位置(或仅复制它,以便进行备份)
  • 使用重新创建服务(这将分配 postgres 作为服务名称)

    pg_ctl register -N postgres -D c:\new\path\to\datadir

  • 启动服务

  • start the service

    net start postgres

  • 运行psql验证Postgres是否已启动并正在运行

  • run psql to verify that Postgres is up and running

    psql -U postgres

  • 验证运行中的服务器正在使用新的数据目录

  • Verify the running server is using the new data directory

    show data_directory;

  • pg_ctl 可以在手册中找到: www.postgresql/docs/current/static/app-pg-ctl.html

    Details on how to use pg_ctl can be found in the manual: www.postgresql/docs/current/static/app-pg-ctl.html

    更多推荐

    如何更改PostgreSQL数据目录?

    本文发布于:2023-10-16 00:26:18,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1495929.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:如何更改   目录   数据   PostgreSQL

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!