Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (4k points)

I´m trying to create a data base from command line. My OS is centos and postgres version is 10.9.

sudo -u postgres psql createdb test
Password for user test:

Why asking me by user?

1 Answer

0 votes
by (8.7k points)

follow the simple to create the database from command line:

  • Switch the user to postgres by executing the following command :

                         su - postgres

  • Creating the user

$ createuser userdemo

  • Creating the needed Database

$ createdb demodatabase

  •  Invoke the psql shell by

 

 

psql [password needed for postgressql]

 

  • After that  you should provide access to the created user as

$ alter user userdemo with encrypted password 'Securix';

$ grant all privileges on database databasedemo to userdemo;

Related questions

0 votes
1 answer
asked Feb 15, 2021 in SQL by RohitSingh (2.6k points)
0 votes
1 answer
asked Dec 6, 2020 in SQL by Appu (6.1k points)
0 votes
2 answers
0 votes
1 answer
0 votes
4 answers
asked Feb 28, 2021 in SQL by adhiraj (4k points)

Browse Categories

...