PostGreSQL数据库两种登陆方式(postgresql数据库两种登陆方式的区别)
方法1:
psql postgresql://postgres:pg123@172.17.0.3:5434/postgres
postgresql协议名称
postgresql 用户名
pg123 密码
172.17.0.3 ip
5434 port
postgres 需要访问的数据库名称
方法2:
psql -U postgres -h172.17.0.3 -p5434 -dpostgres
-U 用户名
-h 数据库IP
-p 数据库端口
-d 需要访问的数据库名称
如果想用psql直接连接数据库,需要通过设置postgres用户的环境变量来实现:
export PGHOME=/usr/pgsql-13
export PGUSER=postgres
export PGPORT=5434
export PGHOST=localhost
export PATH=$PGHOME/bin:$PATH:$HOME/bin