How to recover a password for my heroku postgresql database? I used this command heroku pg:credentials DATABASE --reset but can't gain access to my django admin.
You can see your current credentials with heroku pg:credentials DATABASE or heroku config. You can then use the elements of the URL displayed to connect via a DB admin tool like Pgadmin. The password is the text between the : and the #.
Related
I am trying to migrate to a PostgreSQL db in RDS from Django. The db was set up successfully but when I run python3 manage.py migrate I keep getting the error 'FATAL: password authentication failed for user'. The user name that it mentions is not the master username from RDS which is the same as my USER in settings. I have a .env file with the USER, ENGINE, PASSWORD etc that is being read correctly apart from the fact that it is not referencing the USER. It is referencing the username I use to log onto the computer which I also used when I set up a superuser in the venv.
I have tried logging out from superuser which did nothing. I also tried deactivating the venv which seemed to solve the authentication issue though obviously none of the modules within the venv uploaded so I got errors from that.
I tried changing the password in RDS but it is still trying to connect using the wrong user. I also tried making a new venv but still got the same error. The NAME in settings is set to postgres.
Has anyone else had this issue?
After updating the django settings.py default database to correct values.
i am able to run makemigrations and migrate command and also create super user. but when i login to the admin it gives me error of “no such table - auth user, OPERATIONAL ERROR”.
I noticed that even if i delete db.sqlite3 file, it comes back when i try to login, i think django looks for table in db.sqlite3 and not postgres.
why db.sqlite3 file re appear after deleting ?
how do i correctly configure my settings.py ?
i am integration using digitalocean managed database services with django installed in one droplet, i have integrated both preciously without error but i installed postgres, this is the first time using managed database service.
Thanks
It seems that your django settings are still pointing to the SQlite database.
Did you reload your WSGI process ? If not, the old SQlite settings are still used in memory.
I am running Heroku Django app with post-gre. On my local machine, I have the same app with local db. Now wanted to import my data from local db to heroku db. I am following this guide. I have created a dump file from local db using:
PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mylocaldb > mylocaldb.dump
I have uploaded this dump file to Dropbox. On heroku terminal when I enter:
heroku pg:backups restore 'link/to/dump/file' DATABASE_URL
The output after selecting app is:
b008 ---restore---> HEROKU_POSTGRESQL_NAVY
Running... 32.8kB
It gets stuck on that XX.XkB and no progress after that. It drops all tables in my heroku db, and does nothing after that (I checked using psql).
My question is:
How do I check logs for this restore process ? (and hence track the error). heroku logs --tail shows nothing related to restore.
My local and heroku db have different name. Is that okay ?
My local db has lots of Users, foreign key, south migrations and admin logs. Is that okay or one has to remove all of them before dumping ?
Do I run "pg:backups restore" before or after running syncdb and and south migrate ?
You can run this command to get the info for the import:
heroku pg:backups info b008
I just ran into a similar issue where I uploaded the file to dropbox and used the share link as the backup URL. However, I failed to change the ?dl=0 param in the URL to 1 which means Heroku was trying to download an HTML file instead of the database dump.
How does one migrate their Django .sql3 development database to heroku?
Per here, and here I tried: heroku pg:psql --app sblic < database.sql3 but my Django admin shows no new uploads (even after syncdb/migrate/ or collectstatic
Perhaps there may be a way to directly upload an sql3 file to Heroku, but I went with the path of clearest certainty (convert local sql3 db to postgre db and upload a dump of postgre db to Heroku via pgbackups tool):
Create a dump of your sql3 database as a json file
With PostgreSql installed and with its bin directory in the Path environment variable, create a postgre user and database (or just plan on using your initial super user account created upon installing postgresql)
Update your settings.py with a reference to your newly created postgre database (note, 'HOST' may need to be set as 'localhost', 'user' is your postgre user login)
run python manage.py syncdb to initiate your new postgre db
Optional: if necessary, truncate your postgre db of contenttypes
load your dump from step 1 (if you have fixture issues, see here)
Now you have a working postgre local db. To migrate, first create a postgre dump
Post your postgre dump somewhere accessible by URL (such as drop box or amazon s3 as suggested in previous link).
Perform pgbackups restore command, referencing your dump url
Your heroku app should now reference the contents of your local db.
Heroku command line tool uses the psql binary. You have to install PostgreSQL on your local development machine to have psql available. From the (documentation)[https://devcenter.heroku.com/articles/heroku-postgresql#pg-psql]:
You must have PostgreSQL installed on your system to use heroku pg:psql.
You can in fact keep using your SQLite database with Heroku, but this is not recommended as it will be rewritten with your local copy if you re-deploy it to another dyno. Migrating the data to psql is recommended as described at https://devcenter.heroku.com/articles/sqlite3
I am creating a Django app on Heroku. While I am testing it locally, finally I am checking by uploading everything to heroku and seeing if it works for real on the remote server as well
To quickstart, I went to the admin panel and created a bunch of data to run the view functions on. When I am pushing the source code to heroku via git (git push heroku master), I also want to push up the database from local to heroku, so that I dont need to enter it again on the server side
How do I achieve this?
Thanks a lot
Grab your the postgres string from your Heroku database using heroku config:get
Look for the Heroku Postgres url (example: HEROKU_POSTGRESQL_RED_URL: postgres://user3123:passkja83kd8#ec2-117-21-174-214.compute-1.amazonaws.com:6212/db982398).
Next, run this on your command line:
pg_dump --host=<host_name> --port=<port> --username=<username> --password --dbname=<dbname> > output.sql
The terminal will ask for your password then run it and dump it into output.sql.
Then import it:
psql -d <heroku postgres string> -f output.sql
Note: in each place where you see <.....> in the above code, be sure to substitute your specific information. Thus you would put your username where it says <username>, and your heroku database url where it says <heroku postgres string>.
Similar answer here.