简体   繁体   中英

How can I do to access to psql using bash?

I am trying to do a bash file to use psql but I don't achieve...

Here is my file:

sudo su -
su - postgres
psql

But when I launch my bash file I have to type my password for the root user but then I have close my root session to see the others command executed...

How can I do that to execute the following command as root:

su - postgres
psql

Thank you very much !

That could be combined to something like:

sudo -u postgres psql

However, this should only be done for initial set up and maintenance operations. Create another database account which can accessed without sudo for everyday use. (This might involve changing pg_hba.conf away from its original defaults).

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