Search Posts

Category: Database

Export and Import Postgresql Database

To import a database from another PostgreSQL database into a Docker PostgreSQL container, you can use the pg_dump and psql tools. Here’s a step-by-step guide to achieve this: Step 1: Export the Database from the Source PostgreSQL On the source PostgreSQL server, use the pg_dump tool to create a dump file of the database you […]

Install Postgres

Automated repository configuration: sudo apt install -y postgresql-common sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh Step 1: Update the Package List sudo apt update Step 2: Install PostgreSQL sudo apt install -y postgresql postgresql-contrib Step 3: Install PostGIS sudo apt install -y postgis postgresql-16-postgis-3 replace the 16 with version i have installed to check the version psql –version Step 4: […]

psql commands

Connect remote PostgreSQL psql -U admin -h 192.168.1.5 -p 2506 -d mydatabae List all databases psql -l List users SELECT rolname FROM pg_roles; Show current database SELECT current_database(); Show all tables in database \dt database List databases \l Connect to database “` \c <database_name> Show current database SELECT current_database(); Create database CREATE DATABASE <database_name> WITH […]

Create User & Database

sudo mysql -u root -p CREATE DATABASE my_database; CREATE USER 'my_user'@'localhost' IDENTIFIED BY 'secure_password'; GRANT ALL PRIVILEGES ON my_database.* TO 'my_user'@'localhost'; FLUSH PRIVILEGES; EXIT;