PostgreSQL学习第六篇--psql常用连接数据库的方法

来源:互联网 发布:天庭淘宝店 下载 编辑:程序博客网 时间:2024/06/08 10:55
psql -h <hostname or ip> -p <port> [dbname] [username]-h 指定要连接数据库所在的主机名或者IP地址-p 指定连接的数据库端口,最后两个参数是数据库名和用户名。示例:[postgres@single ~]$ psql -h 186.168.100.13 -p 5432 testdb postgrespsql: could not connect to server: Connection refused        Is the server running on host "186.168.100.13" and accepting        TCP/IP connections on port 5432?[postgres@single ~]$ psql -h localhost -p 5432 testdb postgrespsql (9.6.1)Type "help" for help.[postgres@single pgdata]$ vi postgresql.conflisten_addresses = '*'[postgres@single pgdata]$ psql stoppsql: FATAL:  database "stop" does not exist[postgres@single pgdata]$ pg_ctl stopwaiting for server to shut down.... doneserver stopped[postgres@single pgdata]$ pg_ctl startserver starting[postgres@single pgdata]$ LOG:  database system was shut down at 2016-11-17 22:08:59 CSTLOG:  MultiXact member wraparound protections are now enabledLOG:  database system is ready to accept connectionsLOG:  autovacuum launcher started [postgres@single pgdata]$ psql -h 186.168.100.13 -p 5432 testdb postgresFATAL:  no pg_hba.conf entry for host "186.168.100.13", user "postgres", database "testdb"psql: FATAL:  no pg_hba.conf entry for host "186.168.100.13", user "postgres", database "testdb"[postgres@single pgdata]$ vi pg_hba.conf# IPv4 local connections:host    all             all              186.168.100.13/32       trust [postgres@single pgdata]$ pg_ctl stopLOG:  received fast shutdown requestLOG:  aborting any active transactionsLOG:  autovacuum launcher shutting downLOG:  shutting downwaiting for server to shut down....LOG:  database system is shut down doneserver stopped[postgres@single pgdata]$[postgres@single pgdata]$ pg_ctl startserver starting[postgres@single pgdata]$ LOG:  database system was shut down at 2016-11-17 22:16:14 CSTLOG:  MultiXact member wraparound protections are now enabledLOG:  database system is ready to accept connectionsLOG:  autovacuum launcher started[postgres@single pgdata]$[postgres@single pgdata]$ psql -h 186.168.100.13 -p 5432 testdb postgrespsql (9.6.1)Type "help" for help.testdb=# 

0 0
原创粉丝点击