Using docker-compose:
Create a directory postgresql_data.
mkdir postgresql_data
Create docker volume for postgresql_data:
docker volume create postgresql_data
*Now create a docker-compose.yml file and paste the following code: *
version: '3.8'
services:
pg_database:
image: postgres:14.9-alpine
restart: always
volumes:
- ./postgresql_data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
ports:
- '5455:5432'
volumes:
postgresql_data:
*Now run: *
docker-compose up --build -d
Install only postgres client for terminal:
sudo apt install postgresql-client
Connect from the terminal to your database:
psql -U postgres -p 5455 -h localhost;
Now create your own database to start working :
create database ecommerce_crud;
*Insert dump sql into database : *
psql -U postgres -p 5455 -h localhost -d nodalnda < nodal_dump_local2024_04_29_20_00.sql
Postgres Basic command:
\l ; is same as show databases in mysql;
\d+ products; is same as show create table products ;
\c morning_fresh_bakery; same as use country_db in mysql;
\dt; show tables in mysql;
\d users describe table;
DROP DATABASE nodalnda WITH (FORCE);
Top comments (0)