0

I need to create a database inside using a particular username and import the .sql file using PostgreSQL and Ubuntu. I have created one user using the below command.

sudo -u postgres createuser user1 -s

I need command to create one database spesh under this particular owner and import the spesh.sql into it.

2
  • You're creating a new database for each user? That can't possibly scale to lots of users. Wouldn't a better design be a central repository with a USER table? Commented Sep 7, 2016 at 11:48
  • @duffymo : i needed to create it under that particular owner. Commented Sep 7, 2016 at 11:49

1 Answer 1

5

create db spesh with owner user1

sudo -u postgres createdb "spesh" -O user1

import sql dump into spesh database

sudo -u postgres psql spesh < 'file_path.sql'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.