WillUpdate
WillUpdate

Reputation: 53

Permission denied when trying pg_restore in Google Colab

I'm trying to restore a postgres database in google colab. The code I use is the following:

from google.colab import drive
drive.mount('/content/gdrive')

!apt-get update
!apt-get install -y postgresql postgresql-contrib

!service postgresql start

!sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'my_password';"
!sudo -u postgres createdb mydb

!chmod +x /content/gdrive/MyDrive/db/dataset.dump

!sudo -u postgres pg_restore --verbose --clean --no-acl --no-owner -d mydb /content/gdrive/MyDrive/db/dataset

But I get the following error: pg_restore: error: could not open input file "/content/gdrive/MyDrive/db/dataset.dump": Permission denied

The file is correctly located, I tried with something else and the error signaled that the file in cause did not exist, but in this situation all it says is permission denied. Do you have any suggestions on how I should proceed?

Upvotes: 0

Views: 50

Answers (0)

Related Questions