import .sql file into postgres using psql
up vote
0
down vote
favorite
Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Password for user postgres:
psql (10.6)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.
postgres=# create database mydb;
CREATE DATABASE
postgres=# psql -d mydb -f Telnet.sql;
ERROR: syntax error at or near "psql"
LINE 1: psql -d mydb -f Telnet.sql;
^postgres=#
/*I am not able to figure out the error
I have tried a number of other commands as well but I am not able to figure out the issue.
postgresql
add a comment |
up vote
0
down vote
favorite
Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Password for user postgres:
psql (10.6)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.
postgres=# create database mydb;
CREATE DATABASE
postgres=# psql -d mydb -f Telnet.sql;
ERROR: syntax error at or near "psql"
LINE 1: psql -d mydb -f Telnet.sql;
^postgres=#
/*I am not able to figure out the error
I have tried a number of other commands as well but I am not able to figure out the issue.
postgresql
2
Possible duplicate of How do I run an SQL file in PostgreSQL using a Linux terminal?
– muradm
Nov 11 at 4:29
You are trying to run thepsql
command line while already being connected to the database through psql. You have to come out (runq
)and execute that command from your host machine's command prompt.
– Kaushik Nayak
Nov 11 at 4:56
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Password for user postgres:
psql (10.6)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.
postgres=# create database mydb;
CREATE DATABASE
postgres=# psql -d mydb -f Telnet.sql;
ERROR: syntax error at or near "psql"
LINE 1: psql -d mydb -f Telnet.sql;
^postgres=#
/*I am not able to figure out the error
I have tried a number of other commands as well but I am not able to figure out the issue.
postgresql
Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Password for user postgres:
psql (10.6)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.
postgres=# create database mydb;
CREATE DATABASE
postgres=# psql -d mydb -f Telnet.sql;
ERROR: syntax error at or near "psql"
LINE 1: psql -d mydb -f Telnet.sql;
^postgres=#
/*I am not able to figure out the error
I have tried a number of other commands as well but I am not able to figure out the issue.
postgresql
postgresql
asked Nov 11 at 3:53
Proloy Choudhury
1
1
2
Possible duplicate of How do I run an SQL file in PostgreSQL using a Linux terminal?
– muradm
Nov 11 at 4:29
You are trying to run thepsql
command line while already being connected to the database through psql. You have to come out (runq
)and execute that command from your host machine's command prompt.
– Kaushik Nayak
Nov 11 at 4:56
add a comment |
2
Possible duplicate of How do I run an SQL file in PostgreSQL using a Linux terminal?
– muradm
Nov 11 at 4:29
You are trying to run thepsql
command line while already being connected to the database through psql. You have to come out (runq
)and execute that command from your host machine's command prompt.
– Kaushik Nayak
Nov 11 at 4:56
2
2
Possible duplicate of How do I run an SQL file in PostgreSQL using a Linux terminal?
– muradm
Nov 11 at 4:29
Possible duplicate of How do I run an SQL file in PostgreSQL using a Linux terminal?
– muradm
Nov 11 at 4:29
You are trying to run the
psql
command line while already being connected to the database through psql. You have to come out (run q
)and execute that command from your host machine's command prompt.– Kaushik Nayak
Nov 11 at 4:56
You are trying to run the
psql
command line while already being connected to the database through psql. You have to come out (run q
)and execute that command from your host machine's command prompt.– Kaushik Nayak
Nov 11 at 4:56
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You are already running psql
so you can only execute SQL commands or psql specific commands
To connect to the newly created database use the psql
command c
:
postgres=# c mydb
The prompt should then change to
mydb=#
To run a SQL script from within psql
use the psql
command i
mydb=# i Telnet.sql
Note that psql
commands (those starting with ) are not terminated with
;
- that is only necessary for SQL commands.
You are now connected to database "mydb" as user "postgres". mydb=# i Telnet.sql; Telnet.sql: No such file or directory mydb=#
– Proloy Choudhury
Nov 11 at 20:58
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You are already running psql
so you can only execute SQL commands or psql specific commands
To connect to the newly created database use the psql
command c
:
postgres=# c mydb
The prompt should then change to
mydb=#
To run a SQL script from within psql
use the psql
command i
mydb=# i Telnet.sql
Note that psql
commands (those starting with ) are not terminated with
;
- that is only necessary for SQL commands.
You are now connected to database "mydb" as user "postgres". mydb=# i Telnet.sql; Telnet.sql: No such file or directory mydb=#
– Proloy Choudhury
Nov 11 at 20:58
add a comment |
up vote
0
down vote
You are already running psql
so you can only execute SQL commands or psql specific commands
To connect to the newly created database use the psql
command c
:
postgres=# c mydb
The prompt should then change to
mydb=#
To run a SQL script from within psql
use the psql
command i
mydb=# i Telnet.sql
Note that psql
commands (those starting with ) are not terminated with
;
- that is only necessary for SQL commands.
You are now connected to database "mydb" as user "postgres". mydb=# i Telnet.sql; Telnet.sql: No such file or directory mydb=#
– Proloy Choudhury
Nov 11 at 20:58
add a comment |
up vote
0
down vote
up vote
0
down vote
You are already running psql
so you can only execute SQL commands or psql specific commands
To connect to the newly created database use the psql
command c
:
postgres=# c mydb
The prompt should then change to
mydb=#
To run a SQL script from within psql
use the psql
command i
mydb=# i Telnet.sql
Note that psql
commands (those starting with ) are not terminated with
;
- that is only necessary for SQL commands.
You are already running psql
so you can only execute SQL commands or psql specific commands
To connect to the newly created database use the psql
command c
:
postgres=# c mydb
The prompt should then change to
mydb=#
To run a SQL script from within psql
use the psql
command i
mydb=# i Telnet.sql
Note that psql
commands (those starting with ) are not terminated with
;
- that is only necessary for SQL commands.
answered Nov 11 at 8:51
a_horse_with_no_name
286k45432527
286k45432527
You are now connected to database "mydb" as user "postgres". mydb=# i Telnet.sql; Telnet.sql: No such file or directory mydb=#
– Proloy Choudhury
Nov 11 at 20:58
add a comment |
You are now connected to database "mydb" as user "postgres". mydb=# i Telnet.sql; Telnet.sql: No such file or directory mydb=#
– Proloy Choudhury
Nov 11 at 20:58
You are now connected to database "mydb" as user "postgres". mydb=# i Telnet.sql; Telnet.sql: No such file or directory mydb=#
– Proloy Choudhury
Nov 11 at 20:58
You are now connected to database "mydb" as user "postgres". mydb=# i Telnet.sql; Telnet.sql: No such file or directory mydb=#
– Proloy Choudhury
Nov 11 at 20:58
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245701%2fimport-sql-file-into-postgres-using-psql%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Possible duplicate of How do I run an SQL file in PostgreSQL using a Linux terminal?
– muradm
Nov 11 at 4:29
You are trying to run the
psql
command line while already being connected to the database through psql. You have to come out (runq
)and execute that command from your host machine's command prompt.– Kaushik Nayak
Nov 11 at 4:56