美文网首页
postgresql基础操作

postgresql基础操作

作者: n37r06u3 | 来源:发表于2016-08-02 10:04 被阅读42次

远程访问

postgresql.conf
listen_addresses = '*'
port = 5432

pg_hba.conf
host all all 0.0.0.0/0 md5

命令行
su postgres -c psql

创建用户
create user 'myuser' with password 'mypass' createdb;
重设密码
\password 'myuser'

导出sql
pg_dump --host localhost --port 15432 --username myuser-d mydb> mydb.sql

导入
mv mydb.sql /tmp/mydb.sql
psql# CREATE DATABASE mydb OWNER myuser;
psql# \c mydb
psql# \i /tmp/mydb.sql

service postgresql restart

相关文章

网友评论

      本文标题:postgresql基础操作

      本文链接:https://www.haomeiwen.com/subject/dfefsttx.html