- Add
-itosudocommand to use login shell which changes the working directory to the home directory of the postgres user before executing thepsqlcommand (postgres user naturally has thexpermission to its own home directory):Add
-itosudocommand to use login shell which changes the working directory to the home directory of the postgres user before executing thepsqlcommand (postgres user naturally has thexpermission to its own home directory):sudo -i -u postgres psql < setup_dev_db.sql Give postgres user
xpermission to the current working directory by adding it to the group owning the working directory:# Get group owning the current directory stat -c "%G" . # Add postgres user to that group sudo usermod -aG <group above here> postgresGive postgres user
xpermission to the current working directory by givingxpermission to "others" to the working directory. This can be handy e.g., in single user VM-based systems meant for development, such as WSL2 where simplechmod o+x /home/$USERcommand will fix the error.Run the
psqlusing current user which of course have permissions to the current working directory.Before executing the command, change working directory to a directory where postgres user has
xpermission, e.g.,cd /tmp.
sudo -i -u postgres psql < setup_dev_db.sql - Give postgres user
xpermission to the current working directory by adding it to the group owning the working directory:
# Get group owning the current directory stat -c "%G" . # Add postgres user to that group sudo usermod -aG <group above here> postgres Give postgres user
xpermission to the current working directory by givingxpermission to "others" to the working directory. This can be handy e.g., in single user VM-based systems meant for development, such as WSL2 where simplechmod o+x /home/$USERcommand will fix the error.Run the
psqlusing current user which of course have permissions to the current working directory.Before executing the command, change working directory to a directory where postgres user has
xpermission, e.g.,cd /tmp.