Django: permission denied when trying to access database after restore (migration)

前端 未结 3 1770
南方客
南方客 2020-11-30 22:27

I have a django 1.4 app with a populated postgres 9.1 database in development server locally. After successful deployment, I wanted to move the data from local to online dat

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 23:12

    Here's how I fixed mine. I saved myself a ton of a headache by simply changing the user to match the current logged in user of the destination server where the import will happen.

    In my case, the imported db had a user of x (x was also the username for the machine it was running on), and the destination machine had a username of y, and a postgres user of y too.

    Therefore, I simply changed the Database User and Password in my Django settings to match the destination machine's y user details.

    Then did this:

    $ sudo -u postgres psql psql > GRANT ALL PRIVILEGES DATABASE ON mydb TO y;

    Sipping some kool-aid now!

提交回复
热议问题