安装
https://postgresapp.com/
- Download ➜ Move to Applications folder ➜ Double Click
- Click "Initialize" to create a new server
- Configure your $PATH to use the included command line tools (optional):
sudo mkdir -p /etc/paths.d &&
echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
初始化的账号信息:
host | localhost |
---|
Port | 5432 |
User | 系统用户名 |
Database | 系统用户名 |
Password | 无 |
Connection URL | postgresql://localhost |
如果进行了第三部操作,则可以使用在终端登录pg:
命令如下
psql postgres://username:password@host:port/dbname
psql -U username -h hostname -p port -d dbname
举例:
➜ ~ psql -U mist -h localhost -p 5433
psql (13.4)
Type "help" for help.
mist=
➜ ~ psql -U mist -h localhost -p 5433 -d postgres
psql (13.4)
Type "help" for help.
postgres=