Postgresql 使用psql将.sql文件导入postgres

Postgresql 使用psql将.sql文件导入postgres,postgresql,Postgresql,/*我无法找出错误 我还尝试了许多其他命令,但我无法找出问题所在。您已经在运行psql,因此只能执行或命令 要连接到新创建的数据库,请使用psql命令\c: Server [localhost]: Database [postgres]: Port [5432]: Username [postgres]: Password for user postgres: psql (10.6) WARNING: Console code page (437) differs from Windows co

/*我无法找出错误
我还尝试了许多其他命令,但我无法找出问题所在。

您已经在运行
psql
,因此只能执行或命令

要连接到新创建的数据库,请使用
psql
命令
\c

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=#
然后,提示应改为

postgres=# \c mydb
要从
psql
中运行SQL脚本,请使用
psql
命令
\i

mydb=#

请注意,
psql
命令(以
\
开头的命令)不是以
结尾的-这仅对SQL命令是必需的。

您已经在运行
psql
,因此只能执行或命令

要连接到新创建的数据库,请使用
psql
命令
\c

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=#
然后,提示应改为

postgres=# \c mydb
要从
psql
中运行SQL脚本,请使用
psql
命令
\i

mydb=#

请注意,
psql
命令(以
\
开头的命令)不是以
结尾的-这仅对SQL命令是必需的。

可能重复您正在尝试运行
psql
命令行,同时已通过psql连接到数据库。您必须出来(运行
\q
)并从主机的命令提示符执行该命令。可能有重复的用户正在尝试运行
psql
命令行,同时已经通过psql连接到数据库。您必须出来(运行
\q
)并从主机的命令提示符执行该命令。您现在以用户“postgres”的身份连接到数据库“mydb”。mydb=#\i Telnet.sql;Telnet.sql:没有这样的文件或目录mydb=#您现在以用户“postgres”的身份连接到数据库“mydb”。mydb=#\i Telnet.sql;Telnet.sql:没有这样的文件或目录mydb=#