- 登陆数据库
psql -U dbuser -d exampledb -h 127.0.0.1 -p 5432
-U 指定用户
-d 指定数据库
-h 指定服务器
-p指定端口
- 查看当前连接的用户名
select * from curent_user
select user
- 备份和还原
备份
pg_dump -U dbuser -h 127.0.0.1 -p 5432 exampledb > exampledb.sql
还原
psql -U dbuser -h 127.0.0.1 -p 5432 exampledb < exampledb.sql