Postgresql 初始配置:如何以 postgres 用户身份访问? [英] Postgresql initial configuration: How to access as the postgres user?

查看:72
本文介绍了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 用户身份访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆