New machine error after deployment
APP 12595 Stderr:pg::connectionbad (FATAL: For "dbuser"12595 STDERR:):
Surf the internet for a bit, many of the posts are said to modify/etc/postgresql/9.4/main/pg_hba.conf this file, but it is not a good use
Recall the entire database building process
(1) Create a database user Dbuser and specify it as a super user
Sudo-u postgres CreateUser--superuser dbuser
(2) Create the database uppers_staging and specify the owner as Dbuser
Sudo-u postgres createdb-o dbuser uppers_staging
(3) to Dbuser set the login password (before the password is not set when the error psql:fe_sendauth:no password supplied, set the OK)
[Email protected]:/home/ubuntu/campo/shared# sudo-u postgres psqlpsql (9.4.4" Help " for help.postgres=# \password dbuserpostgres=# \q
(4) Log in to view the database
[Email protected]:/home/ubuntu/campo/current#psql-u dbuser-d uppers_staging-h 127.0.0.1Password forUser Dbuser:psql (9.4.4) SSL connection (PROTOCOL:TLSV1.2, cipher:ecdhe-rsa-aes256-gcm-sha384, bits:256, Compression:off) Type" Help" forhelp.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 |
Permissions for Dbuser
uppers_staging=> \du | Attributes | -----------+------------------------------------------------+----------- dbuser | | {} postgres | Superuser, create role, create DB, Replication | {} root | Superuser, create role, create DB | {}
Next need to tell the database uppers_staging all permissions are assigned to Dbuser, otherwise dbuser can only log in to the console, there is no permission to manipulate the database
GRANT all privileges on the DATABASE uppers_staging to Dbuser;
Then look at the database list
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
The reason for the error is that there is no authorization @[email protected]
The common database operations commands are as follows
\h: View an explanation of the SQL command, such as \h Select. \?: View the list of PSQL commands. \l: Lists all databases. \c [database_name]: Connect to a different database. \d: Lists all tables for the current database. \d [table_name]: Lists the structure of a table. \DU: Lists all users. \e: Opens a text editor. \conninfo: Lists the current database and connection information.
Pg::connectionbad (Fatal:peer authentication failed