简体   繁体   中英

Configuring Username and Password in PostgreSQL

I have just reset my password in psql by editing my pg_hba.conf file to

local  all  all  trust

before changing it back to

local  all  all  md5

after. After doing this I tried to restart the psql server but I found that I have no access to any the server through the pg_ctl commands, for example if I try:

pg_ctl -D /Library/PostgreSQL/9.6/data restart

The reply is:

pg_ctl: could not open PID file 
"/Library/PostgreSQL/9.6/data/postmaster.pid": Permission denied 

The only way that I'm able to open psql is with this command:

 psql -U postgres

Because if I try just 'psql', the response is the following:

psql: FATAL:  role "robertosullivan" does not exist

I need to find some way of connecting to psql with my username and my new password so that I can use psql with my app in Rails.

Any advice would be much appreciated, thanks.

First of all, "robertosullivan" does not exist. Which means that you have configured your PG with a user account that simply isn't there. Seems like the easiest way around this would be to create the user like so:

sudo -u postgres createuser robertosullivan -s
sudo -u postgres psql
postgres=# \password your-password

以下查询可能对您有帮助

psql -h localhost -U postgres -d postgres

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM