Question:
Create postgres database
# createdb mydb
response could be like this:
createdb: could not connect to database postgres: FATAL: role "root" does not exist
createdb: could not connect to database template1: FATAL: role "root" does not exist
where your own login name is mentioned. 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.) If you are the administrator, see Chapter 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 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 user , such as ” root “
Look at :
# Database administrative login by Unix domain socket local all postgres peer
Change to :
# Database administrative login by Unix domain socket local all postgres trust
Step 3: save ” pg_hba.conf “file and reload PostgreSQL service
# sudo /etc/init.d/postgresql reload
Step 4: createdb successfully
# createdb mydb -U postgres
Leave a Reply
You must be logged in to post a comment.