简体   繁体   中英

How to import an .sql file into a Postgres database?

When I run the following command to import the sql DB into PostgreSQL,

psql -U homestead -h localhost <DB Name> < <backup.sql>

it throws the following syntax error.

ERROR:  unrecognized configuration parameter "sql_mode"
ERROR:  unrecognized configuration parameter "time_zone"
ERROR:  syntax error at or near "`"
LINE 1: CREATE TABLE IF NOT EXISTS `addresses` (

Any idea to resolve this issue. Thanks in advance.

You can simply use mysqldump to create your .sql file.
mysqldump -u username -p --compatible=postgresql databasename > outputfile.sql
Now you can import .sql in your postgresql database without any error.
Hope this help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM