我正在尝试连接到一个像这样的数据库:
psycopg2.connect(database="movies", user="lfcj", host="127.0.0.1");
我的pg_hba.conf
文件有一行:
类型 __ 数据库___用户__地址___方法
local all lfcj peer
我正在尝试使用对等认证,我的操作系统用户名也是lfcj
。
当我像这样登录postgresql,授予所有权限给lfcj
,并运行\list
:
psql lfcj -h 127.0.0.1 -d movies
Enter password: 'myPassword'
psql (9.4.1)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
movies=# GRANT ALL PRIVILEGES ON DATABASE movies TO lfcj WITH GRANT OPTION;
movies=#\list
I get this information:
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
--------+----------+----------+-------------+-------------+-----------------------
movies | lfcj | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/lfcj +
| | | | | lfcj=C*T*c*/lfcj+
因此:数据库
movies
已经存在,lfcj
是所有特权的所有者。但是当我运行以下命令时:psycopg2.connect(movies, lfcj);
会抛出一个错误:File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
psycopg2.OperationalError: FATAL: database "movies" does not exist
有什么想法吗?