Postgresql 初始配置:如何以 postgres 用户身份访问?

编程入门 行业动态 更新时间:2024-10-25 13:23:44
本文介绍了Postgresql 初始配置:如何以 postgres 用户身份访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

安装postgresql后,我试了一下,输入createdb mydb,就像文档里写的一样.然后出现如下错误:

After installing postgresql, I tried it out, typing createdb mydb, like it's written in the documentation. Then the following error occured:

createdb: could not connect to database postgres: FATAL: role "xxx" does not exist

我研究了文档,其中说:

I studied the documentation, where is said:

您需要成为安装 PostgreSQL 的操作系统用户(通常是 postgres)才能创建第一个用户帐户

You will need to become the operating system user under which PostgreSQL was installed (usually postgres) to create the first user account

我通过访问 psql(在我的例子中使用 sudo -u postgres psql,使用 Ubuntu 12.10)来尝试这个.但那我该怎么办?

I tried this by accessing psql (in my case with sudo -u postgres psql, using Ubuntu 12.10). But then what should I do?

推荐答案

如果数据库归用户 postgres 所有,您可以执行以下操作

if the db is owned by user postgres you can do the following

createdb -U postgres 数据库名

因为默认情况下 postgresql 将信任来自本地主机的连接.

since by default postgresql will trust connections from localhost.

更多推荐

Postgresql 初始配置:如何以 postgres 用户身份访问?

本文发布于:2023-10-22 08:34:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1516995.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:身份   用户   Postgresql   postgres

发布评论

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

>www.elefans.com

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