初次登陆postgreSQL
gpadmin Greenplum 超级用户
[gpadmin@greenplum gpconfig]$ psql postgres gpadmin
postgres=# \d
No relations found.
postgres=# \l
List of databases
Name | Owner | Encoding | Access privileges
-----------+---------+----------+---------------------
postgres | gpadmin | UTF8 |
template0 | gpadmin | UTF8 | =c/gpadmin
: gpadmin=CTc/gpadmin
template1 | gpadmin | UTF8 | =c/gpadmin
: gpadmin=CTc/gpadmin
(3 rows)
##postgres=#create database gp_test_db ower gp_test;
##postgres=#create user gp_test with passowrd 'test' login gp_test_db;
postgres=# CREATE USER gp_test WITH PASSWORD 'test' ;
NOTICE: resource queue required -- using default resource queue "pg_default"
CREATE ROLE
postgres=# ALTER DATABASE gp_test_db OWNER TO gp_test ;
ALTER DATABASE
postgres=# \l
List of databases
Name | Owner | Encoding | Access privileges
------------------+---------+----------+---------------------
gp_test_db | gp_test | UTF8 |
my_test | gpadmin | UTF8 |
postgres | gpadmin | UTF8 |
template0 | gpadmin | UTF8 | =c/gpadmin
: gpadmin=CTc/gpadmin
template1 | gpadmin | UTF8 | =c/gpadmin
: gpadmin=CTc/gpadmin
test_of_database | gpadmin | UTF8 |
tmp_test1 | gpadmin | UTF8 |
(7 rows)
当切换到gp_test用户是报错
gp_test_db=# \!psql -U gp_test -d gp_test_db
psql: FATAL: no pg_hba.conf entry for host "[local]", user "gp_test", database "gp_test_db", SSL off
此时修改
[gpadmin@greenplum ~]$ vim /data/master_database/gpseg-1/pg_hba.conf
host all gp_test 127.0.0.1/32 md5
host all gp_test 192.168.6.154/32 md5
32是子网掩码的网段;md5是密码验证方法
然后重启配置文件
[gpadmin@greenplum ~]$ gpstop -u
20131022:17:10:59:022547 gpstop:greenplum:gpadmin-[INFO]:-Starting gpstop with args: -u
20131022:17:10:59:022547 gpstop:greenplum:gpadmin-[INFO]:-Gathering information and validating the environment...
20131022:17:10:59:022547 gpstop:greenplum:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information
20131022:17:10:59:022547 gpstop:greenplum:gpadmin-[INFO]:-Obtaining Segment details from master...
20131022:17:10:59:022547 gpstop:greenplum:gpadmin-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 4.2.1.0 build 3'
20131022:17:10:59:022547 gpstop:greenplum:gpadmin-[INFO]:-Signalling all postmaster processes to reload
.
此时切换用户成功
gp_test_db=# \!psql -U gp_test -d gp_test_db -h greenplum;
Password for user gp_test:
psql (8.2.15)
Type "help" for help.
gp_test_db=> \c gp_test_db
You are now connected to database "gp_test_db"as user "gp_test".
psql -p 5432 -U gpadmin -c 'select code_id,count(*) from code_month2 group by code_id'
[gpadmin@greenplum gpconfig]$ psql -U gp_test -d gp_test_db -h greenplum
Password for user gp_test:
psql (8.2.15)
Type "help" for help.
gp_test_db=>