1.切換用戶
[root@master scripts]# su - postgres
-bash-4.1
2.登陸postpostgresql控制檯
-bash-4.1$ psql
postgres=#
3. 進入ambari庫
postgres=# \c ambari
ambari=#
4.授予ambari用戶對ambari庫的權限
ambari=# grant postgres to ambari;
GRANT ROLE
ambari=# grant all privileges on database ambari to ambari;
GRANT
5.退出
ambari=# \q
6.重新使用amabri用戶進入postgresql(默認密碼bigdata)
[root@master scripts]# su - postgres
-bash-4.1$ psql -U ambari
Password for user ambari:
psql (8.4.20)
Type "help" for help.ambari=>
7.列舉數據庫
ambari=> \l
8.列舉表
ambari=> \dt
9.查看錶結構
ambari=> \d users
10.Select查詢
ambari=> select * from host_version;
11.切換數據庫
ambari=>\c dbName