postgresql (1): use psql to import database

Import the database using psql

1 Overview

Hello everyone, I am Ouyang Fangchao.
I heard that postgresql is becoming more and more popular? psql is a powerful command-line tool for managing and manipulating PostgreSQL databases. It provides an interactive environment that allows users to execute SQL queries, create and manage databases, perform backups and restores, and more. Today, I moved the company's pg library to a Windows machine. I encountered a problem in the process of using the psql command, so I will record it.

2. Specific issues

When using the psql command on Windows, I get this error:

psql: 致命错误: 用户 "xxx" Password 认证失败

This is because the user of the pg database is not specified. By default, the user of Windows is used, and this user does not exist in the pg database. Generally, the initial user name of the pg database is postgres, and all user names are specified using the -U command. You can:

C:\Program Files\PostgreSQL\10\bin>psql.exe -p 5432 -d hubei  -U postgres < D:\tools\xxx.sql

In the above command, the username and database name are specified by using -U and -d options. These options can be omitted if the database is on the local host and the default port number (5432) is used.

3. Summary

Another small step on the road to growth.
I'm Ouyang Fangchao, and I'm interested in doing things well. If you like my article, please like, forward, comment and pay attention. See you next time.
The picture below was taken in the company while working overtime:

insert image description here

Guess you like

Origin blog.csdn.net/u012288582/article/details/131583897
Recommended