PostgreSql:createdb -U postgres mydb 错误:createdb: could not connect to database postgres: FATAL: P

PostgreSql:createdb -U postgres mydb 错误:createdb: could not connect to database postgres: FATAL: P,第1张

概述 *** 作系统: Ubuntu   运行下面的命令创建名为mydb的数据库 createdb mydb 得到一个错误:psql: FATAL: role "terry" does not exist, terry是我的机器名, 在postgresql数据库中没有名为terry的role, 所以会报出这个错误, 只要加上-U参数来指定一个存在的role就可以了,所以我将上面的命令改为: createdb

*** 作系统: Ubuntu

运行下面的命令创建名为mydb的数据库

createdb mydb 

得到一个错误:psql: FATAL: role "terry" does not exist, terry是我的机器名, 在postgresql数据库中没有名为terry的role, 所以会报出这个错误, 只要加上-U参数来指定一个存在的role就可以了,所以我将上面的命令改为:

createdb mydb -U postgres

又得到一个错误:psql: FATAL: Peer authentication Failed for user "postgres",解决办法如下:

1. 运行下面的命令编辑pg_hba.conf文件

sudo gedit /etc/postgresql/9.1/main/pg_hba.conf

2. 将

# Database administrative login by Unix domain socketlocal   all             postgres                                peer

改为

# Database administrative login by Unix domain socketlocal   all             postgres                                trust

3. 保存后执行下面的命令重新加载配置文件:

sudo /etc/init.d/postgresql reload

再执行 createdb mydb1 -U postgres , 已经成功的创建了mydb1数据库.

总结

以上是内存溢出为你收集整理的PostgreSql:createdb -U postgres mydb 错误:createdb: could not connect to database postgres: FATAL: P全部内容,希望文章能够帮你解决PostgreSql:createdb -U postgres mydb 错误:createdb: could not connect to database postgres: FATAL: P所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1176695.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存