# TYPE DATABASE USER CIDR-ADDRESS METHOD
68
69 # "local" is for Unix domain socket connections only
70 local all all password
71 # IPv4 local connections:
72 host all all 127.0.0.1/32 password
73 # IPv6 local connections:
74 host all all ::1/128 ident
75
76 host all all 10.1.30.0/24 password
77 #host all all 127.0.0.1 password
78
上面是pg_hba.conf 的内容
创建用户
create user a with password 'a';
创建数据库
create database db1 encoding='UTF-8';
create database db1 encoding='UTF-8' template template0
如果还不行
create database db1 encoding='UTF-8' LC_CTYPE='zh_CN.UTF-8' LC_COLLATE='zh_CN.UTF-8' template template0;
\l 查看数据库
\du 查看用户
这是登录命令,可以在root用户下登录,必须先改配置成trust
psql -h 127.0.0.1 -U a db1
CREATE USER a WITH PASSWORD '1' SUPERUSER;
alter user postgres with password '1'
passwd postgres
建表
这是远程客户端登表
psql -h 127.0.0.1 -U postgres
\c db1; 切换数据库命令
\d 显示所有表
68
69 # "local" is for Unix domain socket connections only
70 local all all password
71 # IPv4 local connections:
72 host all all 127.0.0.1/32 password
73 # IPv6 local connections:
74 host all all ::1/128 ident
75
76 host all all 10.1.30.0/24 password
77 #host all all 127.0.0.1 password
78
上面是pg_hba.conf 的内容
创建用户
create user a with password 'a';
创建数据库
create database db1 encoding='UTF-8';
create database db1 encoding='UTF-8' template template0
如果还不行
create database db1 encoding='UTF-8' LC_CTYPE='zh_CN.UTF-8' LC_COLLATE='zh_CN.UTF-8' template template0;
\l 查看数据库
\du 查看用户
这是登录命令,可以在root用户下登录,必须先改配置成trust
psql -h 127.0.0.1 -U a db1
CREATE USER a WITH PASSWORD '1' SUPERUSER;
alter user postgres with password '1'
passwd postgres
建表
这是远程客户端登表
psql -h 127.0.0.1 -U postgres
\c db1; 切换数据库命令
\d 显示所有表