Postgresql initial configuration: How to access as the postgres user?

拜拜、爱过 提交于 2021-02-05 11:02:41

问题


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:

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

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


回答1:


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

createdb -U postgres dbname

since by default postgresql will trust connections from localhost.




回答2:


su - postgres

and after you have been logged in:

createdb mydb


来源:https://stackoverflow.com/questions/15641488/postgresql-initial-configuration-how-to-access-as-the-postgres-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!