0

I am trying to copy a table from one database to another database But no response in server

Here is the command

pg_dump -U database_user_name -t categories my_current_db_name | psql new_db_name

What wrong in the above code it is not showing any response.

6
  • Does that table already exist in new_db_name? The dump will generate a table creation script unless you add a flag for content only... Commented Jan 2, 2014 at 21:13
  • Perhaps pass -U database_user_name to the psql command as well. Also, can you post the exact error you are seeing? Commented Jan 2, 2014 at 21:14
  • psql: FATAL: password authentication failed for user "root" This is the error message but I did not use root user in the above syntax Commented Jan 2, 2014 at 21:18
  • Perhaps run this as postgres user: sudo -u postgres pg_dump -U database_user_name ... Commented Jan 2, 2014 at 21:33
  • If you are running as root (a bad idea), then "psql" without "-U" will try to connect to postgresql as root. Commented Jan 3, 2014 at 0:22

1 Answer 1

2

If something does not work then divide it into smaller problems.

At first try to run:

pg_dump -U database_user_name -t categories my_current_db_name

What is it printing? Do you see error message or correct dump output?

Then try to run:

psql new_db_name

Is it able to connect to database?

Possible problems:

  1. new_db_name does not exists
  2. you cannot connect with source or destination database because of wrong user/password/db host/port
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.