Postgresql cannot change to root with -u shortcut

Postgresql cannot change to root with -u shortcut

bash usr lib command not found permission denied
su failed to execute /bin/bash: permission denied redhat
su user bash: /root/bashrc permission denied
bash: permission denied root
failed to run command '/bin/bash': permission denied
linux can t su to root
permission denied when logged in as root
su failed to exec permission denied

Recently updated from Postgresql 9.1 to 9.3.

Everything works fine, but I noticed now when I type in:

sudo -u postgres psql

I am getting hit with a permission denied error for changing dir to root.

"Could not change directory to /home/root.

However, when I use:

sudo su - postgres 
psql

It accesses it fine. How can I fix this?


change directory to someplace that postgres has access to:

cd /tmp
sudo -u postgres psql

How To Customize the PostgreSQL Prompt with psqlrc on Ubuntu , The psqlrc file customizes the behavior of the psql interactive command line Now you can switch to the postgres user and start psql. the main psql prompt (​PROMPT1) and create useful shortcuts. is normally = %# refers to whether you'​re a superuser (#) or a regular user (>) Could not load preview. Stack Overflow Public questions and answers Teams Private questions and answers for your team Enterprise Private self-hosted questions and answers for your enterprise


Try this:

sudo -i -u postgres psql

This accomplishes (almost) the same thing as your

sudo su - postgres 

The - in the above indicates that you want to use the postgres account's environment. If you remove the -, it will fail similarly to sudo -u

The -i indicates that you want to run the postgres account's login shell (hence cding to their home directory).

[PDF] PostgreSQL Installation Guide, Installing PostgreSQL with the Graphical Installation Wizard . graphical installer by right clicking on the name of the installer and selecting Run as administrator superuser and the PostgreSQL service account. Use the --create_shortcuts parameter to specify whether menu shortcuts If you still cannot. Try this: Re: could not change directory to "/root": Apparently you did "su postgres" from the root account, so you're still in root's home directory. It'd be better to do "su - postgres" to ensure you've acquired all of the postgres account's environment.


For me this did the trick (or you'll get a could not change directory to "/root": Permission denied), pay attention to quotes (')

sudo -Hiu postgres 'pg_dump --column-inserts --data-only --table=someTable entities_db > /var/backups/anywhere/$(date +%Y%m%d_%H%M%S)_someTable.sql'

Note the -Hiufor sudo, or use su - postgres

you can also put that in a cronjob for root with crontab -e

Configure pgAdmin 4, installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu Only use sudo if the stack was installed as root. port for the nodes in this solution cannot be accessed over a public IP address. Edit the file installdir/postgresql/data/postgresql.conf and replace this line 8 Postgresql cannot change to root with -u shortcut Jul 17 '17 3 Django-MPTT - ordering root nodes by count of immediate descendants Aug 8 '17 View all questions and answers →


pgadmin4 : postgresql application server could not be contacted , 1. right click pgAdmin 4 icon 2. select "Run As Administrator" I had the same issue on Windows 10, with a new installation of PostgreSQL 10. Make sure you​'re starting the right version of pgAdmin (your shortcuts are likely to point to this answer (https://superuser.com/a/1131964) regarding python but I  Kirk Roybal. DBA at Cognizant. Some dude. 14 Postgresql cannot change to root with -u shortcut Mar 4 '16. 4 Automating install and creation of postgresql


(Embedded PostgreSQL) The application server could not be , After upgrading the embedded PostgreSQL database version from 9.4.22 to 10.9 in version 2019.11, pgAdmin4 fails to lanuch on Linux  ALTER ROLE changes the attributes of a PostgreSQL role. The first variant of this command listed in the synopsis can change many of the role attributes that can be specified in CREATE ROLE . (All the possible attributes are covered, except that there are no options for adding or removing memberships; use GRANT and REVOKE for that.)


Problem with SSL certificate setup, -subj is a shortcut to avoid prompting for the info. directory. root.crt (trusted root certificate) postgresql.crt (client ciphers # (change requires restart) LOG: 08P01: could not accept SSL connection: tlsv1 alert unknown ca ALTER ROLE changes the attributes of a PostgreSQL role. The first variant of this command listed in the synopsis can change many of the role attributes that can be specified in CREATE ROLE . (All the possible attributes are covered, except that there are no options for adding or removing memberships; use GRANT and REVOKE for that.)