Can't see tables in pgAdmin4 that were created through dockerized PostgreSQL - postgresql

I'm running PostgreSQL through a Docker container. I entered the container and used psql to connect to postgres. I created two databases then created a table in test_db. I checked pgAdmin4 and the databases were there but the students table is not showing up in the UI. Not sure why if the databases are showing up?

I see you connected to 'test_db' database in pgadmin, but to 'postgres' database in psql. If you want to see 'students' table from 'test_db' database in psql, you need connect to 'test_db' database firstly instead of 'postgres' database. You can use '\c test_db' command for that in psql, or '-d test_db' command-line parameter when launching psql from command line.

Related

Issue with Postgres roles after exporting then restoring from Heroku

I'm new to Postgres and Heroku. I've inherited a project with a Postgres DB hosted on Heroku and I'd like to export it from there for local use inside Docker. I've got as far as exporting and then restoring (via pg_restore) the DB inside my container, but when it builds my DB I get loads of warnings like:
pg_restore: from TOC entry 285; 1259 16897 TABLE foo u2ae1fgct609sl
pg_restore: error: could not execute query: ERROR: role "u2ae1fgct609sl" does not exist
Command was: ALTER TABLE public.foo OWNER TO u2ae1fgct609sl;
Presumablty this is because I've exported/restored the DB but not the corresponding users. Heroku doesn't seem to mention this part in its docs on exporting/restoring/importing Postgres DBs.
What can I do about this? Can I somehow tell it to set as the owner the DB user that Docker created when spinning up the container, or am I on the wrong lines?

Postgres add user impossible

I get from customer Postgres 8.4, a very strange edition
I login with Postgres user under trust settings.
But in pgAdmin i got a lot of relations errors
I thought normally tables should goes to DB Catalogs Tables, but here DB Catalogs Tables not exists or i cant see them, all tables i see in db Schemas, and database is working as i can access it through ODBC and Postgres connector, but then i see all 2809 tables i a row without separation. It like multi tenat services, but misconfigured or not suit with pgAdmin.
From pgAdmin i cant create any user and roles, from ssh psql created user cant connect through odbc or Postgres connector, and do not appears in pgAdmin Login/Group Roles tab.
So why i cant access in pgAdmin4 Login/Group Roles tab?
Why cant create user from pgAdmin4?
Why cant access pg_catalogs from pgAdmin4?
Why user created from ssh psql cant access database from ODBC or Postgres connector? (got always table is empty)
If this is multi tenant services why it not work like expected from pgAdmin?
PgAdmin 4 version 5.6
PgAdmin4 says it supports 9.5 and newer. 8.4 is not newer than 9.5.

Cannot drop db in postgres [duplicate]

I can't seem to reset my database while using docker compose. I've tried killing the server, killing just the database, and restarting the machine.
Anyone know the best way to clear out the development database?
Here's what I tried:
docker-compose run web rake db:reset
I am getting this error:
PG::ObjectInUse: ERROR: cannot drop the currently open database
: DROP DATABASE IF EXISTS "postgres"
Couldn't drop database 'postgres'
rake aborted!
I'm using the setup exactly as described by the docker-compose quickstart: https://docs.docker.com/compose/rails/
I have a rails container and a postgres container
You are using the wrong database.
The database postgres is normally not used for user data, but for administrative purposes. For example, if you want to drop a database, you have to be connected to a different database in the PostgreSQL database cluster to issue the SQL statement DROP DATABASE. Normally, the database postgres is used for that purpose, and I have no doubt that Docker does exactly that when it tries to drop a database.
If you really want to drop the database postgres, you'd have to connect to some other database in the cluster. The correct solution, however, is to keep your data in a different database. Then the problem should go away by itself.

Switch between databases in PGAdmin4

How we can connect to specific database by using sql commands in pgadmin4 postgresql
in psql command line,its already working \c database name,same thing we want to connect to specific database in pgadmin4 postgresql
The pgadmin4 SQL window executes only SQL commands, which are bound to a specific database. \c is an internal psql command.
You need to open separate SQL windows per database in pgadmin4.

PostgreSQL - create a new DB through pgAdmin UI

I have installed PostgreSQL DB server on my Ubuntu machine. Now I want to create a new Database through some GUI application. I tried pgAdmin but didn't find any option to create a new DB. But I could add existing db servers.
Is there any way to create a DB and then tables through pgAdmin or some other app.
Basically I am looking for an application for PostgreSQL like SQLYog for MySQL.
Open pgAdmin
Connect to database server
Edit => New Object => New database
done
Or use plain SQL when connection to any database: CREATE DATABASE my_database;
HI ... Verify that u have done above steps to install the postgresql properly ... and follow the below instructions to create a database in POSTGRESQL
INSTALL POSTGRESQL
1.Install latest PostgreSQL 9.1 in console:
sudo apt-get install postgresql libpq-dev
2.PostgreSQL has a super user is called postgres. Change user to the PostgreSQL user:
sudo su - postgres
3.Change password of postgres user:
psql -d postgres -U postgres
psql (9.1.3) Type "help" for help
postgres=# alter user postgres with password 'YOUR_NEW_PASSWORD';
ALTER ROLE
postgres=# \q
#logout postgres user
logout
4.Restart the PostgreSQL server:
sudo /etc/init.d/postgresql restart
pgAdmin III: PostgreSQL administration and management tools
If pgAdminIII is not installed, the installation is easy:
sudo apt-get install pgadmin3
ADD A SEVER
Open pgAdminIII and add new localhost server. Go to menu File > Add Server
Set up pgAdmin III server instrumentation:
When connecting to a PostgreSQL database using pgAdmin you may receive an error letting you know that the server instrumentation is not installed.
Install postgresql-contrib package:
sudo apt-get install postgresql-contrib
Install adminpack extension:
sudo -u postgres psql
postgres=# CREATE EXTENSION "adminpack";
postgres=# \q
CREATE DATABASE
1.Double Click your database in Left pane on PGAdmin to select it
2.Now click the a Icon named "SQL" ,probably 6th icon, and type CREATE table query in resultant window
EXAMPLE:
3.Create table query
CREATE TABLE explore(
SUBJECT TEXT NOT NULL,
COMPANY CHAR(50) NOT NULL,
PNAME TEXT NOT NULL,
PHONE INT NOT NULL,
EMAIL CHAR(50) NOT NULL,
REMARKS CHAR(200) NOT NULL
);
Post any queries below.............Have a error free day.
One of problems with DB creating is connected to permissions.
If there are no grant for creating database, the path "Object -> Create -> Database" is off (unclickable) and you can't pick this menu option. Likewise, "Databases -> Right Mouse Button" doesn't have "Create" option. One more sign of this case is the reaction in SQL:
CREATE DATABASE DBNAME;
ERROR: permission denied to create database
********** Error **********
To solve the problem you can reconnect to the Server with the first login ('postgres' for example). And afterwards the menu will work.
Of course you can create a database with pgAdmin.
You have to understand the basic concept of PostgreSQL. First you have to connect to a database cluster, which you can only do by connecting to a database in that cluster. Now, if your database does not exist, yet, there is the default maintenance db postgres you can connect to. Connect to it and issue CREATE DATABASE there. Then change to the new database.
On windows right click on the db connector
My db connector is PostgreSQL->Create->Database, expand the database
Next expand schema
under which tables is found, then right click, and create tables
To create tables Expand database->under that expand schema->under tables , click on create tables
To add columns and data types to tables
under the respective table, right click properties and select column fields and add name of columns, data types as needed properties->columns
So, I'm late to the party, but it seems that regular old PG_Admin, and the EnterpriseDB installation are different packages. PG_Admin by itself just manages and connects to servers, but doesn't seem to create them. This is definitely not clear, but yeah you get those errors because you're trying to connect to a server that doesn't exist. You could also use WSL to do this, but you'd have to have WSL and your server up and running everytime to you play.