I am running PostgreSQL 9.3 on my machine. I have PhpPgAdmin running on a cloud, using which I exported the database I am supposed to be working on, selecting "Structure and Data" and "Download". There is an sql file generated. On my machine however, I open my PgAdmin3 client , initialize my databases and run the following import command
psql -U postgres -d postgres -f dump.sql
Nothing happens. I also tried
psql postgres < /path/to/dump.sql
But again nothing happens. I tried on both Windows as well as Linux Mint because I thought it was something wrong with my installation on Windows. I am new to PostgreSQL and the equivalent for it in MySQL using PhpMyAdmin was simple. Am I missing any security things? I think not because just so that nothing gets confused, I saved all my names as postgres itself.
I have researched everywhere but nothing so far. Any help would be appreciated. Thanks!
1 Answer 1
The PSQL Console
in pgadmin3 consists of opening a terminal and running psql --username yourname [other options] dbname
inside it for you, with yourname
and dbname
being taken from what you've used to log in pgadmin3.
This console runs the psql
interpreter which expects either psql
meta-commands starting with backslash, or plain SQL commands.
When typing this:
`psql -U postgres -d postgres -f dump.sql`
it's taken as an unfinished SQL sentence for the interpreter, so it's just waiting for the rest. That's why nothing happens as you wrote. This command is out of context.
What you want is:
\i /path/to/dump.sql
\i
means 'include' and is the meta-command to feed a file as a stream of SQL commands to the interpreter.
You'll see the output of these commands on the terminal and when finished , type \q
to end the session.
-
But according to the manual
-f
should be equivalent to\i
user1822– user18222014年06月23日 08:18:08 +00:00Commented Jun 23, 2014 at 8:18 -
@Daniel Verite : Thanks for that suggestion. I tried it but now it says ERROR : Syntax Error at or near "'" - LINE 1 INSERT INTO ... Similar error with ALTER TABLE instead INSERT INTO as well. I did not change anything at all in the dump. Here is the screenshot. bayimg.com/baocOAAfOValarMorghulis– ValarMorghulis2014年06月23日 09:29:46 +00:00Commented Jun 23, 2014 at 9:29
-
1@George: your dump is apparently for MySQL, not PostgreSQL. It encloses table names between backticks like only MySQL does.Daniel Vérité– Daniel Vérité2014年06月23日 09:32:12 +00:00Commented Jun 23, 2014 at 9:32
-
@a_horse_with_no_name: the asker doesn't get the option to use
-f
because the psql command line invocation is generated by pgadmin.Daniel Vérité– Daniel Vérité2014年06月23日 09:32:57 +00:00Commented Jun 23, 2014 at 9:32
Explore related questions
See similar questions with these tags.
psql
from pgAdmin? At least what you write suggests that. It won't work. You should run it from the command line or open the dump in the pgAdmin query tool and run it from there.