【发布时间】:2015-07-02 16:34:40
【问题描述】:
所以我在 Ubuntu 上安装了 postgresql9.3。 现在我必须创建一个新用户。因此,使用超级用户 postgres 一切皆有可能。但我需要为每个新数据库创建一个新用户。
所以我做了什么:
sudo -u postgres psql
CREATE USER python with PASSWORD 'python';
CREATE DATABASE dbpython;
GRANT ALL PRIVILEGES ON DATABASE dbpython to python;
我还修改了/etc/postgresql/9.1/main/pg_hba.conf文件,将本地frompeer的认证设置改为md5。
重新启动 postgres 后,我想使用我的新用户:
ubuntu@ip-172-31-33-139:~$ su python
No passwd entry for user 'python'
但是
ubuntu@ip-172-31-33-139:~$ sudo service postgresql restart
* Restarting PostgreSQL 9.3 database server [ OK ]
ubuntu@ip-172-31-33-139:~$ psql -d dbpython -U python
Password for user python:
psql (9.3.6)
Type "help" for help.
dbpython=>
为什么能正常工作而 su python 不能? 重要说明:我没有在我的 Ubuntu 中创建新的 python 用户,我希望 postgres 上的每个新用户都不需要这样做。
【问题讨论】:
标签: sql postgresql ubuntu