在postgresql9.6中创建用户
运行psql, 用create role 带login参数才能登录。
先在 pg_hba.conf中的缺省设置下,即有下列设置项(local all postgres peer)下,通过root用户,进入到postgres 用户下,运行 psql进入postgresql命令行状态,修改postgres的口令,通过以下命令:
alter roll postgresq password "###############" ;
修改后,再注释掉(local all postgres peer), 使用 (local all all md5),就能够在任何用户下,运行psql -U username -d dbname -W 进入postgresq 命令行下了,一定要有-d postgres 这个参数。
psql -U username -d postgres -W
在用pip install -r requirements.txt --user 安装odoo11时,遇到以下错误,加上
--user 参数即可。
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/ldapurl.py'
Consider using the `--user` option or check the permissions.
安装linux库扩展:
aptitude install -y python3.5-dev python3-postgresql libxml2-dev libxslt-dev libevent-dev libsasl2-dev libldap2-dev
aptitude install -y npm
npm install -g less
ubuntu 16.04 在安装 odoo11.0 时,需做这个安装 aptitude install -y node-less
psql: FATAL: Peer authentication failed for user “postgres” (or any user)
The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).
If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.
But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:
from
# TYPE DATABASE USER ADDRESS METHOD
local all all peer
to
# TYPE DATABASE USER ADDRESS METHOD
local all all md5
-
peermeans it will trust the identity (authenticity) of UNIX user. So not asking for a password. -
md5means it will always ask for a password, and validate it after hashing withMD5. -
trustmeans it will never ask for a password, and always trust any connection.
You can, of course, also create more specific rules for a specific database or user, with some users having peer and others requiring passwords.
After changing
pg_hba.confyou'll need to restart PostgreSQL if it's running. E.g.sudo service postgresql restart
Steps to change/create default postgres user's password:
trustconnection by adding inpg_hba.conffile
local all postgres trust
- Restart postgresql service
sudo service postgresql restart
-
psql -U postgres -
At the
postgres=#prompt, change the user namepostgrespassword:
ALTER USER postgres with password ‘new-password’;
- Revert the changes in
pg_hba.conffile fromtrusttomd5and restartpostgresql.
* The file pg_hba.conf will most likely be at /etc/postgresql/9.x/main/pg_hba.conf
* Source
本文详细介绍了在 PostgreSQL 9.6 中创建用户并进行权限配置的方法,包括通过修改 pg_hba.conf 文件实现不同身份验证机制,如 peer、md5 和 trust 的切换,以及如何在不创建 UNIX 用户的情况下解决连接问题。同时,提供了更改默认 postgres 用户密码的步骤。
9391

被折叠的 条评论
为什么被折叠?



