Createdb Database Creation Failed Error Role Does Not Exist
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers psql: fatal: database "username" does not exist or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question psql fatal role does not exist windows x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; fatal role does not exist rails it only takes a minute: Sign up psql fatal role does not exist up vote 5 down vote favorite 2 I recently the lastest version of ubuntu and i'm not used to it yet. I had several problems connecting postgresql createdb: database creation failed: error: permission denied to create database with pgadmin3. I tryed to follow several tutorials to create a localhost server which I can use in pgadmin3. I didn't really hit the mark and I think I made it worse by installing, uninstalling, installing, uninstalling, trying answers I found... At this point I'm not sure my postgres is clean. It could be possible that I have two postgres installed, once again, I'm not sure. I tryed to uninstall it but I had an error which basicly said postgres
Pg::insufficientprivilege: Error: Permission Denied To Create Database
wasn't in sudo. The thing is I now have this error running psql in the console : $psql psql: FATAL: role "user" does not exist I can't find the pg_hba.conf and at this point I'm too afraid to make things even worse by trying following any other posts. How could I make this work? postgresql ubuntu pgadmin share|improve this question edited Aug 9 at 17:03 Kasper Souren 4,16832661 asked Jan 29 '15 at 11:44 whiplash 30114 pg_hba.conf is irrelevant here. You are trying to connect with the username user - but that account/username/role does not exists. You need to specify an existing database user using the -U switch when starting psql –a_horse_with_no_name Jan 29 '15 at 11:47 Since the error message comes from psql, you are already connected to the DBMS, No need to mess with pg_hba.conf. As the message says: the user name "user" does not exist. BTW: user is a terrible name for a user. Would you call your child child ? –joop Jan 29 '15 at 11:47 I wans't clear but instead of user, that's the name of my session that is written. I'll try all that tonight. –whiplash Jan 30 '15 at 13:31 Possible duplicate of PostgreSQL error: Fatal: role "username" does not exist –Teemu Leisti Aug 17 at 14:30 add a comment| 3 Answers 3 active oldest votes up vote 12 down vote acc
not connect to database postgres: FATAL: Peer authentication failed for user "postgres" Posted by: Yang , July 7, 2014 Question: Create postgres database # createdb mydb response could be like this: createdb: could not
Sudo: Unknown User: Postgres
connect to database postgres: FATAL: role "root" does not exist createdb: could psql fatal: database "root" does not exist not connect to database template1: FATAL: role "root" does not exist where your own login name is mentioned. This postgres role will happen if the administrator has not created a PostgreSQL user account for you. (PostgreSQL user accounts are distinct from operating system user accounts.) If you are the administrator, see Chapter http://stackoverflow.com/questions/28213929/psql-fatal-role-does-not-exist 20 for help creating accounts. You will need to become the operating system user under which PostgreSQL was installed (usually postgres) to create the first user account. It could also be that you were assigned a PostgreSQL user name that is different from your operating system user name; in that case you need to use the -U switch or set the PGUSER http://learn.linksprite.com/pcduino/linux-applications/postgresql-createdb-could-not-connect-to-database-postgres-fatal-peer-authentication-failed-for-user-postgres/ environment variable to specify your PostgreSQL user name. # createdb mydb -U postgres response could be like this: createdb: database creation failed: ERROR: permission denied to create database Not every user has authorization to create new databases. If PostgreSQL refuses to create databases for you then the site administrator needs to grant you permission to create databases. Consult your site administrator if this occurs. If you installed PostgreSQL yourself then you should log in for the purposes of this tutorial under the user account that you started the server as. You can also create databases with other names. PostgreSQL allows you to create any number of databases at a given site. Database names must have an alphabetic first character and are limited to 63 bytes in length. A convenient choice is to create a database with the same name as your current user name. Many tools assume that database name as the default, so it can save you some typing. How to Fix : Step 1: edit pg_hba.conf file # sudo nano /etc/postgresql/9.3/main/pg_hba.conf Step 2 : change " peer " to pcDuino Ubuntu u
for a shell prompt where a user can use the command, root# for a command requiring root access, and postgres=# for a command at the http://www.gilesorr.com/blog/starting-postgres.html PostgeSQL prompt. Setup use apt-get, aptitude, or your preferred graphical installer to install "postgresql" Debian install adds group "postgres", which by default has no entries in it edit /etc/group, add yourself to that group log out and back in to force re-evaluation of what groups you're in check by running giles$ groups command giles$ createdb giles does not gets error createdb: could not connect to database template1: FATAL: role "giles" does not exist even after groups problem corrected according to the documentation: "This will happen if the administrator has not created a PostgreSQL user account for you. (PostgreSQL user accounts are distinct from operating system user accounts.)" so you need to become the "administrator" I initially does not exist assumed this was "root" as the account that installed the application, but when I ran root# createuser giles (yes, PG actually owns that command name) ... but I still get createuser: could not connect to database postgres: FATAL: role "root" does not exist a Debian install creates not only a postgres group, but also a "postgres" user - this is better security policy than "root" being the admin the easiest way (at least the way I do things) is to giles$ su - to become root, and then root# su - postgres as postgres/the DB admin you need to run pguser$ createuser giles, which finally succeeds silently now as user giles I run giles$ createdb giles and get a new error: createdb: database creation failed: ERROR: permission denied to create database from the documentation: "If PostgreSQL refuses to create databases for you then the site administrator needs to grant you permission to create databases." to get to a Postgres prompt and start typing SQL commands, run