Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Basic use of Postgresql

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Under Windows

Service check

Home page to see if the service is running

Find the postgresql service

The service is running

Execute a command

Command line management

Open the cmd command line

Connect database command

Access PostgreSQL database: psql-h IP address-p port-U database name

Errors may occur:

In this case, you need to configure the environment variables of postgresql.

Find the bin folder under the installation directory of disk c

Set environment variabl

Interface settin

Right-click "my computer", click Properties, pop up Properties, and then click Advanced Settings to pop up the Advanced Settings interface.

Click the Environment variable pop-up Environment variable Settings button on system Settings

Select "path" and click "Edit"

Just click New to save.

Command settin

Enter set path

You can see the current variable value of path

Enter set path=% path%; C:\ PostgreSQL\ pg96\ bin; to append our path to the variable

Be careful that there are no spaces in the path. Paths with spaces will not be recognized.

Execute the psql-- help command again after the environment variable has been modified

Indicates that the environment variable is set successfully

Access PostgreSQL database: psql-h IP address-p port-U database name

Psql-h localhost-p 5432-U postgres

Localhost stands for local

5432 is the default port number for postgresql

Postgres is the default user of postgresql

The presence of this screen indicates a successful connection

Enumerate database

\ l command

Will list all the database information and select the database.

\ C Database name

Switch to Test database and pay attention to case sensitivity

Query data from database

Select * from User

Pay attention to the semicolon after';'

Backup database

Pg_dump-h server-p port number-U user name-d dbname-f sql file path

Examples

Pg_dump-h localhost-p 5432-U postgres-d Test-f:\ Test.sql

After the execution is finished, go to the f disk to view the Test.sql file

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report