Postgres 基础使用

Windows 下默认用户 postgres 密码修改

找到data/pg_hba.conf

打开,修改

host all all 127.0.0.1/32 md5

# IPv6 local connections:

host    all             all             ::1/128                 md5

host all all 127.0.0.1/32 trust

# IPv6 local connections:

host    all             all             ::1/128                 trust

然后cmd, 到bin目录下

psql -U postgres

--------------------------

D:\envirment\PostgreSQL\9.2\bin>psql -U postgres

postgres=# alter user postgres with password '123456';

ALTER ROLE

postgres=# \q

---------------------------

然后把pg_hba.conf  在改回来

然后就可以在PG的sql shell下登陆了

 # psql -U postgres -h 127.0.0.1
            2.创建新用户zhaofeng,但不给建数据库的权限
            postgres=# create user “zhaofeng” with password ‘123456’ nocreatedb;
          //注意用户名要用双引号,以区分大小写,密码不用
            3.建立数据库,并指定所有者
           
 postgres=# create database “testdb” with owner=”zhaofeng”;
            4.在外部命令行的管理命令
            # -u postgres createuser -D -P test1
            //
-D该用户没有创建数据库的权利,-P提示输入密码,选择管理类型y/n
            # -u postgres createdb -O test1 db1
            //
-O设定所有者为test1

 

猜你喜欢

转载自patrick002.iteye.com/blog/2207085