vi /var/lib/pgsql/9.2/data/postgresql.conf
listen_addresses = '*' 修改为监听所有ip地址的连接请求
vi /var/lib/pgsql/9.2/data/pg_hba.conf
任意网段中的任意主机;trust——免密码登录
host all all 0.0.0.0/0 trust
二、
使用postgres登录psql -h 127.0.0.1 -p 5432 -U postgres,登录后却出现以下问题,
postgres=> create database d1;
ERROR: permission denied to create database
postgres=> CREATE ROLE tdw;
ERROR: permission denied to create role
postgres=> drop role dd;
ERROR: permission denied to drop role
postgres=> ALTER USER postgres WITH SUPERUSER;
ERROR: must be superuser to alter superusers
解决:
[root@bigdata2 data]# sudo -u postgres /usr/pgsql-9.2/bin/postgres --single -D /var/lib/pgsql/9.2/data/
Postgresql stand-alone backend 9.2.8
backend> ALTER USER postgres WITH SUPERUSER;
backend>
查看:
三、
postgres=> drop database global;
ERROR: must be owner of database global
解决:
使用global的owner用户登录,psql -h 127.0.0.1 -p 5432 -U hive-d postgres
四、命令总结
service postgresql-9.2 stop
service postgresql-9.2 start
service postgresql-9.2 status
[root@jstorm3 build]# psql --version
psql (Postgresql) 9.2.8
登录PG
psql -h 127.0.0.1 -p 5432 -U postgres
指定数据库
psql -h 127.0.0.1 -p 5432 -U postgres -d postgres
查看所有用户密码
select * from pg_shadow;
ALTER USER hive WITH PASSWORD '123456';
ALTER TABLE public.pb_proto_jar OWNER TO postgres;
CREATE TABLE t1(cdate TIMESTAMP,c2 INT);
INSERT INTO t1 VALUES(now(),1);
原文链接:https://www.f2er.com/postgresql/195401.html