Windows under
Service check
Home to see if the service is running
Find PostgreSQL Services
Service is running
Execute command
- Command line Management
Open cmd command line
Connect Database command
Access PostgreSQL database: PSQL-H IP address-P Port-U database name
An error may occur:
In this case, the environment variable configuration of PostgreSQL needs to be done
Locate the Bin folder in the installation directory of the C drive
Setting environment variables
Interface settings
Right click on the "My Computer" button properties, pop-up properties, and then click Advanced Settings Pop-up advanced Settings screen
Click on "Environment variables" on "System settings" to eject environment variable Settings button
Check "path" and click "Edit"
Click New to save
- Command settings
Enter set path
You can see the current variable value of path
Input set path=%path%; C:\PostgreSQL\pg96\bin: You can append our path to the variable
Note that paths do not have spaces, and paths with spaces are not recognized
Execute the psql--help command again after the environment variable is 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 indicates a local
5432 is the default port number for PostgreSQL
Postgres is the default user for PostgreSQL
This screen appears to indicate a successful connection
- Enumerating databases
\l Command
All database information is listed
- Select Database
\c Database name
Switch to the test database, note the case-sensitive
Querying data from the database
Select * from User;
Notice the semicolon in the back '; '
Backing Up the database
Pg_dump–h Server –p port number –U user name –d dbname–f SQL file path
Example
Pg_dump-h localhost-p 5432-u postgres-d test-f f:\Test.sql
After execution, view the Test.sql file under the F-drive
Basic use of PostgreSQL