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.










share|improve this question


















  • 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 (run q)and execute that command from your host machine's command prompt.
    – Kaushik Nayak
    Nov 11 at 4:56

















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.










share|improve this question


















  • 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 (run q)and execute that command from your host machine's command prompt.
    – Kaushik Nayak
    Nov 11 at 4:56















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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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
















  • 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 (run q)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














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.






share|improve this answer





















  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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

























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.






share|improve this answer





















  • 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















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.






share|improve this answer





















  • 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













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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python