标签:
部署完的新机器报错
App 12595 stderr: PG::ConnectionBad (FATAL: Peer authentication failed for user "dbuser" App 12595 stderr: ):
回忆一下整个数据库的搭建过程
(1)创建数据库用户dbuser,并指定为超级用户
sudo -u postgres createuser --superuser dbuser
sudo -u postgres createdb -O dbuser uppers_staging
# sudo -u postgres psql psql (9.4.4) Type "help" for help. postgres=# \password dbuser Enter new password: Enter it again: postgres=# \q
(4)登录查看下数据库
# psql -U dbuser -d uppers_staging -h 127.0.0.1 Password for user dbuser: psql (9.4.4) SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) Type "help" for help. uppers_staging=> \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges --------------------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres uppers_development | root | UTF8 | en_US.UTF-8 | en_US.UTF-8 | uppers_staging | dbuser | UTF8 | en_US.UTF-8 | en_US.UTF-8 | (5 rows)
uppers_staging=> \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------+----------- dbuser | | {} postgres | Superuser, Create role, Create DB, Replication | {} root | Superuser, Create role, Create DB | {}
GRANT ALL PRIVILEGES ON DATABASE uppers_staging to dbuser;
uppers_staging=> \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges --------------------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres uppers_development | root | UTF8 | en_US.UTF-8 | en_US.UTF-8 | uppers_staging | dbuser | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/dbuser + | | | | | dbuser=CTc/dbuser (5 rows)
常见的操作命令如下
\h:查看SQL命令的解释,比如\h select。 \?:查看psql命令列表。 \l:列出所有数据库。 \c [database_name]:连接其他数据库。 \d:列出当前数据库的所有表格。 \d [table_name]:列出某一张表格的结构。 \du:列出所有用户。 \e:打开文本编辑器。 \conninfo:列出当前数据库和连接的信息。
版权声明:本文为博主原创文章,未经博主允许不得转载。
PostgreSQL新手上路PG::ConnectionBad (FATAL: Peer authentication failed
标签:
原文地址:http://blog.csdn.net/shiralwz/article/details/47980035