su - postgres --切换用户<br>psql --进入sql面板<br>alter user postgres with password 'postgres'; --修改密码,默认没有密码<br>\q --退出sql面板<br>exit --退出postgres用户shell会话<br><br>
复制代码
配置外网也可以连接数据库<br>
复制代码
/var/lib/pgsql/12/data/pg_hba.conf(<br>输入“:86”跳转86行;<br>按“i”编辑模式;<br>================================按照如下修改<br># IPv4 local connections:<br>host all all 0.0.0.0/0 md5<br># IPv6 local connections:<br>host all all ::1/128 md5<br>================================<br>按“Esc”退出编辑模式<br>输入“:wq”保存退出)<br><br>vi /var/lib/pgsql/12/data/postgresql.conf(<br>:60 --跳转60行<br>将“#listen_addresses = 'localhost'”改为 “listen_addresses = '*'”)