PostgreSQL

Command

shell:
sudo -u postgres createuser --superuser dbuser
sudo -u postgres createdb -O dbuser exampledb

psql : postgres console
psql -U postgres
psql -U postgres -d postgres -h 127.0.0.1 -p 5432
psql -U postgres -f file.sql

postgres console:
\h 查看SQL命令的解释,比如\h select。
\? 查看psql命令列表。
\l 列出所有数据库。
\c [database_name] 连接其他数据库。
\d 列出当前数据库的所有表格。
\d [table_name] 列出某一张表格的结构。
\du 列出所有用户。
\e 打开文本编辑器。
\conninfo 列出当前数据库和连接的信息。
\password user 修改密码
\q 退出
CREATE USER dbuser WITH PASSWORD 'password';
CREATE DATABASE exampledb OWNER dbuser;
GRANT ALL PRIVILEGES ON DATABASE exampledb to dbuser;


Error 

1. GUI client connection 

could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?

Solution:

1. 修改pg_hba.conf

[root@c9t21622 bin]# vim /var/lib/pgsql/9.4/data/pg_hba.conf

添加:

host    all             all             15.107.13.42/23         trust

或修改

#host    all             all             127.0.0.1/32            trust
host    all             all             0.0.0.0/0                trust

2. 修改postgresql.conf (localhost  -> *)

[root@c9t21622 bin]#  vim /var/lib/pgsql/9.4/data/postgresql.conf

57 # - Connection Settings -
58 listen_addresses = '*'      

转载于:https://my.oschina.net/sunjazz/blog/803855

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值