postgresal使用錯誤解決 (記錄篇)
1、
錯誤:psql: FATAL: Peer authentication failed for user "postgres"
解決辦法如下:
1). 執行下面的命令編輯pg_hba.conf檔案 sudo vim /etc/postgresql/9.1/main/pg_hba.conf
2). 將
# Database administrative login by Unix domain socket
local all postgres peer
改為
# Database administrative login by Unix domain socket
local all postgres trust
3). 儲存後執行下面的命令重新載入配置檔案: sudo /etc/init.d/postgresql reload
2、
錯誤:
conn = psycopg2.connect(database="testdb", user="postgres", password="nopasswd", host="127.0.0.1", port="5432")
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
psycopg2.OperationalError: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
用jdbc連線Postgresql資料庫時經常出現這個錯誤,這主要是由於使用者密碼認證方式引起的,Postgresql資料庫安裝好後預設採用md5密碼加密認證方式。
解決方法:
1). 執行下面的命令編輯pg_hba.conf檔案 sudo vim /etc/postgresql/9.1/main/pg_hba.conf
2). 將
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv4 local connections:
host all all 127.0.0.1/32 trust
3). 儲存後執行下面的命令重新載入配置檔案: sudo /etc/init.d/postgresql reload
3、
create index for some fields
解決方法:
1). 執行下面的命令編輯pg_hba.conf檔案 sudo vim /etc/postgresql/9.1/main/pg_hba.conf
2). 將
# "local" is for Unix domain socket connections only
local all all peer //舊版本該處為ident
# "local" is for Unix domain socket connections only
local all all trust
3). 儲存後執行下面的命令重新載入配置檔案: sudo /etc/init.d/postgresql reload
4、psql: FATAL: role root does not exist
在postgresql中建立一個名為root的角色即可:
postgres@debian:~$ createuser root
postgres@debian:~$ psql
psql (9.3.3)
Type "help" for help.
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
long | | {}
postgres | Superuser, Create role, Create DB, Replication | {}
root | | {}
建立完角色之後如果出現以下錯誤:
createdb: database creation failed: ERROR: permission denied to create database 你需要為postgresql進行一些操作的授權(並非所有使用者都經過了建立新資料庫的授權。) 在建立角色時就賦予角色一些屬性,可以使用下面的方法。首先切換到postgres 使用者。
建立角色bella 並賦予其CREATEDB 的許可權。
postgres=# CREATE ROLE bella CREATEDB ;
CREATE ROLE
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
bella | Create DB, Cannot login | {}
david | | {}
postgres | Superuser, Create role, Create DB, Replication | {}
sandy | | {}
CREATE ROLE
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+-------------------------------------------------+-----------
bella | Superuser, Create DB, Cannot login | {}
bellaa | Superuser, Create role, Create DB, Cannot login | {}
bellaaa | Superuser, Create role, Create DB, Replication| {}
postgres | Superuser, Create role, Create DB, Replication | {}
root | Superuser, Create DB | {}
5.在執行以下操作後提示FATAL: role 'root' is not permitted to log in.
後直接將postgres所有許可權都給root後,仍報錯
google後,由於create role時不為使用者賦予login許可權,賦予login許可權即可
postgres=# alter user root login;
ALTER ROLE
6.
psql: FATAL: database "wangye" does not exist
wangye@selfimpro:~$ su postgres
Password:
postgres@selfimpro:/home/wangye$ psql
psql (9.1.14)
Type "help" for help.
postgres@selfimpro:/home/wangye$ createdb wangye -E utf-8
postgres@selfimpro:/home/wangye$ psql wangye
psql (9.1.14)
Type "help" for help.
相關文章
- virtualbox 錯誤解決記錄
- vagrant homestead 錯誤記錄以及解決方案
- Incorrect key file for table '/tmp/....'錯誤的解決--記錄
- Keil RTX使用 os_mut_init 報Hard Fault 錯誤解決記錄
- Kafka錯誤記錄Kafka
- ontape出現段錯誤(未解決篇)
- 記錄錯誤並繼續執行:錯誤事件記錄子句 --轉事件
- C++錯誤記錄C++
- SpringMVC錯誤記錄SpringMVC
- 安裝SQL Server 2005所遇錯誤及解決方法記錄SQLServer
- mysql 解決字符集錯誤 正確摘錄MySql
- Django Admin 錄入中文錯誤解決辦法Django
- 使用putty遠端登入Ubuntu時,報Network error:Connection refused錯誤及解決(記錄)UbuntuError
- 錯誤記錄:apache預設網頁訪問錯誤Apache網頁
- JS錯誤記錄 – dom操作 – 排序JS排序
- 假資料填充錯誤記錄
- 日常python報錯及解決方法記錄Python
- 記錄[Vue+elementUI]報錯及解決方法VueUI
- 記錄一次根據錯誤資訊無法定位錯誤的錯誤
- VIM 常用錯誤解決
- sqldeveloper for windows 錯誤解決SQLDeveloperWindows
- 記錄一次錯誤的使用當前時間new Date()引發的錯誤
- 使用JPEGImageEncoder提示Access restriction:錯誤 解決方案REST
- 《學習Oracle從這裡開始》之解決錯誤篇Oracle
- MongoDB的一次錯誤記錄MongoDB
- 錯誤記錄(八)could not initialize proxy - no SessionSession
- vsftpd 錯誤:530 and 500 錯誤解決方法FTP
- Nginx 405 以及301 解決報錯記錄Nginx
- 執行轉換時如何讓Kettle記錄錯誤並繼續執行?——記一種解決方案
- GDB除錯使用記錄除錯
- latex 錯誤以及解決方案
- ora-27504錯誤解決
- Datastore error in 'dirbdb'錯誤解決ASTError
- ORA-27054 錯誤解決
- mysql與php錯誤解決MySqlPHP
- mysql錯誤解決總結MySql
- 使用Aihubmix API 服務中遇到錯誤與解決AIAPI
- [DBA手記]IMP-00093錯誤的解決方法