- 首先我们需要登陆pg数据库,解压客户端后,进行pgsoft目录下,选择对应版本好的pgsql
cd pgsqoft/pg11.6/bin
- 登陆pgsql
psql -h ip -U user(用户名) -d 数据库名 -p 端口
eg: psql -h 127.0.0.1 -U test -d test -p 5432
- 执行sql脚本
\i 脚本路径.sql
- 退出
\q
- 也可以直接执行脚本
psql -h 127.0.0.1 -U test -d test -p 5432 -a -f 脚本路径.sql