简体   繁体   English

导入/导出 PostgreSQL db “无” pg_dump 或 sql 文件/备份等...?

[英]Import/Export PostgreSQL db “without” pg_dump or sql file / backup, etc…?

I need to import a old db into a new postgre server.我需要将旧数据库导入新的 postgre 服务器。

Is there a way to migrate an old database to a new server without using pg_dump?有没有办法在不使用 pg_dump 的情况下将旧数据库迁移到新服务器?

I don't have the sql file, or the old server backup file, neither the user and the password, just the physical files in the "\data" folder, is there any way to do this?我没有sql文件,也没有旧服务器备份文件,也没有用户和密码,只有“\data”文件夹下的物理文件,有什么办法吗?

The target server is in the same version of th old server.目标服务器与旧服务器的版本相同。

Thanks.谢谢。

Well as a test you could try:作为一个测试,你可以尝试:

pg_ctl start -D $DATA

Where pg_ctl comes from the target version and the $DATA is the the /data directory.其中 pg_ctl 来自目标版本, $DATA是 /data 目录。 You have not said how you came to have just a /data directory.你还没有说你是如何得到一个 /data 目录的。 If this came from an unclean shutdown or a corrupted drive the possibility exists that the server will not start.如果这来自不干净的关机或损坏的驱动器,则可能存在服务器无法启动的情况。

UPDATE更新

To get around auth failure find pg_hba.conf and create or modify local connection to use trust method.要绕过auth失败,请找到 pg_hba.conf 并创建或修改local连接以使用trust方法。 For more info see pg_hba and trust .有关更多信息,请参阅pg_hbatrust Then you should be able to connect like:然后你应该能够像这样连接:

psql -d some_db -U postgres

Once in you can use ALTER ROLE to change password:进入后,您可以使用ALTER ROLE更改密码:

ALTER ROLE <role_name> WITH PASSWORD 'new_password';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM