PGAdmin shows excessive amount of database from Heroku - postgresql

I'm learning some backend stuff, I made a test database locally and filled some data, and then I dump the database to an SQL file with the following command:
pg_dump -U USERNAME DATABASE —no-owner —no-acl -f backup.sql
And finally restore it to Heroku:
heroku pg:psql —app APPNAME < backup.sql
There is only 1 database I’m deploying, however, when I use PGAdmin to connect to it, it shows more than 2000 databases and crashes my computer:
Where are all these databases coming from?

You don't get a dedicated PostgreSQL server with Heroku Postgres. Your databases are co-located with other users' databases on the same server. You'll be able to see the names of other users' databases, but you won't be able to access them.
I'm not sure what "crashes my computer" means, but make sure you are selecting your database when trying to connect.

Related

How to make PostgreSQL database accessible all the time from different computers?

I've created simple PostgreSQL database on my localhost and connected it to my project. I want to pass the project to someone else and share the same database. Also i want my db to run 24h per day and be accessible without previous switching on.
Let's see. It is a lot of spec. Fortunately, the solution for your problem is simple: move your database from local machine (your PC/laptop) to a network-connected server. Below is step-by-step list of what you need to do:
Find a decent PostgreSQL DB provider (some paid, some free), for example: Amazon RDS , ElephantSQL, Azure PostgreSQL. Then create an instance.
Or you can setup a server and install PostgreSQL. Either works fine.
Change the connection from localhost:5432 to new server. There is no detail on question, so I'll provide an example of connection string:
postgres://{remoteuser}:{password}#{remotehost}:{port}/{dbname}
If your local database already contain data, copy it to new database
pg_dump -C -h localhost -U localuser dbname | psql -h remotehost -U remoteuser dbname

Why did SQL syntax change after restoring local Postgres onto AWS RDS?

Problem
A simple 2x2 table of data explains my problem. Both databases can be made to work, but they behave differently and I need them to be the same.
PostreSQL Query | Local DB | Amazon-RDS |
--------------------------+------------+-----------------------------------------+
SELECT * from mydb.users; | Success | Success |
--------------------------+------------+-----------------------------------------+
SELECT * from users; | Success | ERROR: relation "users" does not exist |
---------------------------------------------------------------------------------+
Details
The databases should be identical. Amazon-RDS is literally pg_restore'd from a pg_dump of the local database. Exact commands:
$ pg_dump --format=c ---no-privileges --no-owner --verbose \
--host=localhost --port=5432 --username=gary mydb;
$ pg_restore --no-owner --no-tablespaces --dbname=mydb --verbose \
--host=127.0.0.1 --port=47737 \ #ssh tunnel
--username=XXXXXX --format=c
The problem is not with the data dump itself. I've wiped the local database, restored it from the dump, and it still behaves the way it's supposed to.
The problem doesn't just manifest not just with my raw SQL queries, there's a sizable Node/Express app that is supposed to front-end the database. It generates queries without the database prefix in front of the tables too. The app uses Sequelize for an ORM and has been running with MySQL on Amazon-RDS in
production for years. The issue I'm seeing now has only appeared while migrating from MySQL to PostgreSQL.
I have no experience with Postgres.
I don't think it should matter, but in full disclosure, I'm using DBeaver to handle all my database connections, and do the db dump and restore.
Questions
Why does one database successfully infer the database from the name of the table alone, and not the other cannot?
Is there a configuration setting somewhere to make them both work? mydb is the only database in the RDS instance.
mydb is not a database, it's a schema. And it appears that it is not in the schema search_path on RDS.
It could be configured in the cluster settings, the settings of your database, the settings of your (login) user, or locally on the DBeaver connection.

pgAdmin4: How Can I Get All of my Heroku Postgres Databases to Display in pgAdmin?

I have several Heroku Postgres databases that I want to access using pgAdmin4. I'm using version 4.2. I used this link to learn how to hide the databases I don't have access to. I have all the databases entered in DB restriction. However when I connect to the Heroku database, only the maintenance account appears in the list of databases. I updated the password file in advanced properties with my .pgpass file. It still only lists the maintenance database.
I've searched here, the Database Administrators Stack Exchange, and the pgAdmin instructions but have not found anything.

Restore database from production to Development

We have the database named 'itreport' on production server and database named 'itreport_dev' on development server.
1)On Production server, 52 users are present in the database 'itreport'.
2)On Development server, 60 users are in present the database 'itreport_dev'.
3)I have taken the dump of production server database 'itreport'. Dump file name is backup_12082017.sql
My question is
If I restore the above dump(backup) file to Development server database 'itreport_dev, Users(60) present will present in the Development database?
If not what option we have to give in the restore process?
What are the pre steps and post steps to be performed on Develpement server?
Short answer: No, roles are not part of a single-database backup.
If you dump only the database using pg_dump it will only restore tables and data. not any roles. any objects owned by missing roles will end up owned by the user performing the restore (this user should be a superuser)
If you do pg_dumpall roles and all databases will be backed up.
Roles can be backed up separately using pg_dumpall -r
if you do pgdumpall --clean the resore will destroy and replace any databases and roles on the dev server that also exist in the dump. any names that are not in both will be unaffected, (the special role "postgres" and template databases also are untouched)
pgdumpall backups are SQL backups and should be restores using psql
su postgres -c psql < all-database-backupfile.sql
or
zcat all-database-backupfile.sql.gz | su postgres -c psql
etc.
(for windows use runas instead of su, I'm not sure of the exact syntax needed)

Importing data into two postgres servers works on one, not on other

I dumped my production db from an Amazon RDS postgresql instance and on occasion, I restore production to our staging and development databases.
Currently the staging and development databases reside on an RDS instance and the import works great. I am currently attempting to restore the database to a postgres installation that isn't an RDS instance and I continuously get the error invalid command \N before that I get ERROR: relation "locations" does not exist. I have been trying everything to get this to work. I have recreated the database several times ensuring all of the settings match what I can see of the RDS instance, and am having no luck.
I am attempting to use psql -h {host} -U {user} -d {db} < production.sql