posgresql

ubuntu下

修改postgres数据库用户的密码为123456

sudo -u postgres psql

postgres=# ALTER USER postgres WITH PASSWORD '123456';

修改ubuntu操作系统的postgres用户的密码(密码要与数据库用户postgres的密码相同)

sudo passwd –d postgres

sudo -u postgres passwd

vi /etc/postgresql/9.4/main/postgresql.conf

#listen_addresses = 'localhost' 改为 listen_addresses = '*'

#password_encryption = on 改为 password_encryption = on

vi /etc/postgresql/9.4/main/pg_hba.conf

在文档末尾加上以下内容

host all all 0.0.0.0 0.0.0.0 md5

 

psql -U postgres -h 127.0.0.1

postgres=# create user "dev" with password '123456' nocreatedb;
用户名处是双引号
建立数据库,并指定所有者
postgres=#create database "testdb" with owner = "dev";

 

命令行管理用户 (dev 是用户,tempdb是数据库)

sudo -u postgres createuser -D –P dev

sudo -u postgres createdb –O dev tempdb

posted @ 2016-11-13 12:25  anjunact  阅读(450)  评论(0编辑  收藏  举报