我正在设置PostgreSQL 9.1。我不能用PostgreSQL做任何事情:不能createdb,不能createuser;所有操作都返回错误消息
Fatal: role h9uest does not exist
h9uest是我的帐户名,我在这个帐户下执行apt-get安装PostgreSQL 9.1。 根帐户仍然存在类似的错误。
我正在设置PostgreSQL 9.1。我不能用PostgreSQL做任何事情:不能createdb,不能createuser;所有操作都返回错误消息
Fatal: role h9uest does not exist
h9uest是我的帐户名,我在这个帐户下执行apt-get安装PostgreSQL 9.1。 根帐户仍然存在类似的错误。
当前回答
psql postgres
postgres=# CREATE ROLE username superuser;
postgres=# ALTER ROLE username WITH LOGIN;
其他回答
按照以下步骤让postgres工作。
在终端中,使用以下命令找到应用程序支持文件夹。 /Users/[用户名]/库/应用程序支持 删除应用程序Postgres。 重新安装应用程序,它应该工作得很好。
这对我来说很管用:
psql -h localhost -U postgres
遵循以下步骤,它将为你工作:
run msfconsole type db_console some information will be shown to you chose the information who tell you to make: db_connect user:pass@host:port.../database sorry I don't remember it but it's like this one then replace the user and the password and the host and the database with the information included in the database.yml in the emplacement: /usr/share/metasploit-framework/config you will see. rebuilding the model cache in the background. Type apt-get update && apt-get upgrade after the update restart the terminal and lunch msfconsole and it works you can check that by typing in msfconsole: msf>db_status you will see that it's connected.
在我的案例中,手动创建一个DB集群解决了这个问题。
由于某种原因,当我安装postgres时,没有创建“初始DB”。执行initdb对我来说很管用。
这个解决方案在PostgreSQL Wiki -第一步:
initdb 通常情况下,在操作系统中安装postgres会创建一个“初始DB”,并启动postgres服务器守护进程。如果没有,则需要运行initdb
在本地用户提示符,而不是根用户提示符中键入
sudo -u postgres createuser <local username>
输入本地用户密码。
然后输入前面的命令,生成“角色‘username’不存在”。
以上步骤为我解决了问题。 如果没有,请发送终端消息进行以上步骤。