Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

createdb: database creation failed: ERROR: permission denied to create database

I am pretty much confused about root user,super user,user and permissions! I am not able to create a database inside user "athleticu". Following are the commands I used:-

athleticu@ip-172-30-4-103:/home/ubuntu$ createdb -T template0 simple_db1 createdb: database creation failed: ERROR:  permission denied to create database athleticu@ip-172-30-4-103:/home/ubuntu$ sudo createdb -T template0 simple_db1 sudo: unable to resolve host ip-172-30-4-103 createdb: could not connect to database template1: FATAL:  role "root" does not exist 

Please somebody clarify my doubts and tell me what should I write!

like image 625
SonamGupta Avatar asked May 02 '17 09:05

SonamGupta


Video Answer


1 Answers

Hey I have already solved this. What you have to do is to first login as postgres user as follows:

$ su postgres  $ psql  postgres=# alter user athleticu createdb; ALTER ROLE 

Hope it helps you :)

like image 191
SonamGupta Avatar answered Oct 11 '22 20:10

SonamGupta