How to create superuser and importing sql?

i had problem to creating super user with this command

sudo -u postgres createuser --superuser wahyu

(wahyu is my user name) i've already using root access to do that but i found this

[root@dhcppc41 user]# sudo -u postgres createuser --superuser wahyu
could not change directory to "/home/user"

what should i do?

also, i had problem when trying importing sql or something.. because i dont know, i'm new.

following tutorial here, actually i'm stuck at step 19 and 21, and i need advice. i already ask there, but they won't help.

back to quesion, i dont understand, what should i input in this command.

\i '<path to file>'; 

but found error

no such file or directory

i know this is because i don't know where to input there. i need advice to creating superuser then the location of the sql that have to import. thank you :)

sorry if this question not related with the forum :)

2 Answers

ok this isnt really the forum for this but I will try to answer quickly the first problem is you are in root.

Use your user account .. open a new terminal so you aren't using root then the first command should work.

The other question is not easily answered because I really don't know what this tutorial is showing but its saying to make a database or maybe import one

\c <database> 

is the database name

\i '<path to file>'; 

is where the path to file where the database file will be stored...

so if you had the database name called DB and you want it stored at /home/yourusername/databases the lines would be

\c DB
\i /home/yourusername/databases

I have no way of telling you what you actually need in those lines themselves .. if it is a database that you are supposed to be importing then they should have given that or maybe do give that but ... I didn't go through the whole post.

0

This is how I set up postgresql DB and import database on fresh PC maybe it will help:

  1. Install packages postgresql (server) and pgadmin3 (gui client)
  2. You can't login afterwards through pgadmin anyhow. That's because connect requires password to be filled, and postgres does not have any password filled in. Do this:
    • sudo -u postgres psql
    • alter user postgres PASSWORD 'YourPassword';
    • ctrl + d
  3. now you can run pgadmin, connect to the localhost server with login 'postgres' and new password. Create connection to 'localhost', database postgres, user postgres.
  4. In pgadmin you can create users, import sql database dumps, etc.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like