LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-05-2016, 02:21 AM   #1
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Queensland
Distribution: Fedora 30; HP Pavilion 8Gb and Acer Aspire 16Gb; both Intel Core-i7
Posts: 290

Rep: Reputation: 22
Postgresql: having trouble creating myself as user


I have battered my head against the documentation and googled the problem, all without finding an answer.

I have Postgresql installed and the service is running. Using the postgres user I have issued the following commands:
Quote:
postgres=# createuser doug -P
postgres-# createdb --owner=doug dougsdb
Logged in as me (doug, obviousy) I am unable to get a connection:
Quote:
[doug@KETCHUP ~]$ psql
psql: FATAL: no pg_hba.conf entry for host "[local]", user "doug", database "doug", SSL off
OK, it is looking for the wong database, so I pass the correct name on the command line:
Quote:
[doug@KETCHUP ~]$ psql dougsdb
psql: FATAL: no pg_hba.conf entry for host "[local]", user "doug", database "dougsdb", SSL off
Hmmm ... what if I try from the postgres user's account:
Quote:
-bash-4.3$ psql -h localhost -U doug dougsdb
Password for user doug:
psql: FATAL: password authentication failed for user "doug"
Odd. I know I used the right password. Oh, well, log into the database and reset the password:
Quote:
psql (9.5.4)
Type "help" for help.

postgres=# \password doug
Enter new password:
Enter it again:
ERROR: role "doug" does not exist
What? I have created my user account, but that did not create a matching rôle? Oh well, go back in and create my rôle:
Quote:
postgres=# CREATE ROLE doug
Now it should work from my user account, but no:
Quote:
[doug@KETCHUP ~]$ psql dougsdb
psql: FATAL: no pg_hba.conf entry for host "[local]", user "doug", database "dougsdb", SSL off
What has gone wrong? Maybe the database I created has a problem:
Quote:
-bash-4.3$ psql -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_AU.UTF-8 | en_AU.UTF-8 |
template0 | postgres | UTF8 | en_AU.UTF-8 | en_AU.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_AU.UTF-8 | en_AU.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
My database does not exist!!

I have tried everything I can think of to set myself up as a user with my own database. What am I doing wrong?

All help gratefully received.

Later...
I found I got further by specifying the host as 'localhost', but I'm still running into the fact that my database has not been created:
Quote:
[doug@KETCHUP ~]$ psql -h localhost dougsdb
Password:
psql: FATAL: database "dougsdb" does not exist
[doug@KETCHUP ~]$ psql -h localhost
Password:
psql: FATAL: database "doug" does not exist
So I recreated it:
Quote:
postgres=# CREATE DATABASE dougsdb WITH OWNER = doug;
CREATE DATABASE
To be sure, I listed databases and found it is now present:
Quote:
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
dougsdb | doug | UTF8 | en_AU.UTF-8 | en_AU.UTF-8 |
postgres | postgres | UTF8 | en_AU.UTF-8 | en_AU.UTF-8 |
template0 | postgres | UTF8 | en_AU.UTF-8 | en_AU.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_AU.UTF-8 | en_AU.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
So I tried from my own user account and magically it worked!
Quote:
[doug@KETCHUP ~]$ psql -h localhost dougsdb
Password:
psql (9.5.4)
Type "help" for help.

dougsdb=#
Don't ask me which of th steps solved my problem, but at least I can stop beating my head against any available hard surface. Thanks for reading.

Last edited by Doug Hutcheson; 11-05-2016 at 02:50 AM. Reason: host is 'localhost', not 'host'.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating databases with PostgreSQL in UTF-8 Mankind75 Linux - Software 0 02-24-2014 10:45 AM
Postgresql - Creating a new database error \/4A Linux - Software 8 04-17-2013 07:46 PM
Trouble Creating User/ Changing Password beantier Linux - Newbie 19 04-09-2008 09:42 AM
trouble creating a user MrSako Linux - Newbie 2 10-08-2006 04:06 PM
trouble creating user accounts krsnachaitanya Linux - Networking 2 02-12-2005 10:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration