使用PostgreSQL的用户(Role)和密码登陆

PostgreSQL可以使用系统的用户进行登录,使用peer方式认证,这样设置较为简单。

如果使用PostgreSQL的用户(Role)和密码登陆,需要切换到postgres用户下,进行配置

sudo -i -u postgres

psql

create user mydata with encrypted password ‘123’; //如果pg_hba.conf设置为md5,需要加密

create database mydata;

grant all privileges on mydata to mydata;

这样就可以通过psql -h 127.0.0.1 -U mydata mydata -W进行登录。

Leave a Reply

您的电子邮箱地址不会被公开。 必填项已用 * 标注

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>