DEV Community

Hamza Mushtaque
Hamza Mushtaque

Posted on

PostgreSQL Basics: How to load PostgreSQL database

In this blog we will be learning how to load any PostgreSQL database
into PostgreSQL database server.

We will be keeping our blogs short and easy to read for making them simple. Hence, we will be targeting one thing at a time in our blog series.

I am assuming, you have PostgreSQL installed on your system.

First, we will launch our psql tool, using following command

>psql
Enter fullscreen mode Exit fullscreen mode

After that, Enter required credentials.

Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Password for user postgres:
Enter fullscreen mode Exit fullscreen mode

then create data base using following statement

postgres=# CREATE DATABASE database_name;
CREATE DATABASE
Enter fullscreen mode Exit fullscreen mode

then exit psql tool by typing exit.

then, navigate to bin folder of your Postgres installation.

after that write following command to load your data into the data you created(assuming we created database named database_name).

pg_restore -U postgres -d database_name C:\sampledb\database_file.tar
Enter fullscreen mode Exit fullscreen mode

here -U postgres identifies postgres user, it would be different if you are using different user.

now, enter password for your user.

Password:
Enter fullscreen mode Exit fullscreen mode

Hurray!!!
We are done!!

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay