2

I am working as a software tester. I want to to test my project locally. So I want to insert the database using the psql command. I tried so many times. I couldn't get to access the login page.

This is what I did:

postgres@naveen-Inspiron-3542:/home/naveen$ psql -U admin docmgr

Password for user admin:  psql (9.5.4) Type "help" for help.

docmgr=> psql docmgr -f /var/www/html/docmgr/application/assets/dd/structs/docmgr_21Oct2016.sql -U admin
docmgr-> \dt No relations found.

docmgr-> \dt No relations found.

docmgr-> select * from admin_users;

ERROR:  syntax error at or
 near "psql" LINE 1: psql docmgr -f
 /var/www/html/docmgr/application/assets/dd/st...
         ^
4
  • contents: sql create table queries. Does not get any error. It shows nothing. When I select a list of table "\dt " . It shows no relation found. I think the command is not working.. Commented Oct 24, 2016 at 9:17
  • The title says "How to dump the sql files in postgres ...", although in your question, you seem to ask "How to dump the sql files into postgres ...". So, what is it? Get data out of Postgres, or get data into Postgres? Commented Oct 24, 2016 at 9:22
  • My hypothesis: the file contains the text -- These are not the dumps you are looking for. Not very likely, but it fits with the information we've been given. Commented Oct 24, 2016 at 9:30
  • How can I check that? Commented Oct 24, 2016 at 9:40

1 Answer 1

4

This is wrong:

docmgr=> psql docmgr -f /var/www/html/docmgr/application/assets/dd/structs/docmgr_21Oct2016.sql

You are running psql from within psql but "psql" is not a SQL statement.

You either need to run directly from the command prompt:

postgres@naveen-Inspiron-3542:/home/naveen$ psql -U admin -d docmgr -f /var/www/html/docmgr/application/assets/dd/structs/docmgr_21Oct2016.sql

Or from within psql you need to use the \i command to run a SQL script:

postgres@naveen-Inspiron-3542:/home/naveen$ psql -U admin docmgr

Password for user admin:  psql (9.5.4) Type "help" for help.

docmgr=> \i /var/www/html/docmgr/application/assets/dd/structs/docmgr_21Oct2016.sql
Sign up to request clarification or add additional context in comments.

2 Comments

postgres@naveen-Inspiron-3542:/home/naveen$ psql -U admin -d docmgr -f /var/www/html/docmgr/application/assets/dd/structs/docmgr_21Oct2016.sql Password for user admin: /var/www/html/docmgr/application/assets/dd/structs/docmgr_21Oct2016.sql: No such file or directory postgres@naveen-Inspiron-3542:/home/naveen$ psql -U admin docmgr Password for user admin: psql (9.5.4) Type "help" for help. docmgr=> \i /var/www/html/docmgr/application/assets/dd/structs/docmgr_21Oct2016.sql /var/www/html/docmgr/application/assets/dd/structs/docmgr_21Oct2016.sql: No such file or directory docmgr=>
Hai.. there is a one more issue. It is insert but when I put username and password. It could not access why?

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.