简体   繁体   English

在PostgreSQl中导入数据库架构失败

[英]Importing database schema in PostgreSQl fails

So I want to import a database schema but it fails. 因此,我想导入数据库架构,但是失败。 PostgreSQL Version is 9.5.11. PostgreSQL版本是9.5.11。 Maybe the command is outdated? 也许命令已经过时了? The user "user" is already set up. 用户“用户”已经设置。 Do I need to pass a password additionally in the command? 我是否还需要在命令中通过密码?

postgres@root:~$ psql -d database -U user -f createdb.sql
psql: FATAL: Peer authentication failed for user "user"

In postgresql by default if you connect using unix socket the authentification is done with the peer method, this means you must use the same login unix and postgresql user. 默认情况下,如果使用unix套接字进行连接,则在postgresql中,身份验证是通过对方法完成的,这意味着您必须使用相同的登录unix和postgresql用户。 Here you try to user the user user but when running psql with the unix user postgres so it won't work. 在这里,您尝试使用user 用户,但是当以unix用户postgres运行psql时,它将无法工作。 There is many different solutions, do you action as user postgres under postgres and then change the ownership later, or create a unix user calles user and do the action with it. 有许多不同的解决方案,您可以在postgres下以用户postgres的身份进行操作,然后在以后更改所有权,还是创建一个unix用户调用user并对其进行操作。 You may define a password for the user postgres and connect on the loopback too. 您可以为用户postgres定义密码,也可以在环回上连接。 But if you don't understand how pg_hba.conf works it's not a good idea to modify it. 但是,如果您不了解pg_hba.conf的工作方式,那么修改它不是一个好主意。

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

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