Report this

What is the reason for this report?

How to import a postgresql database

Posted on October 25, 2022

I tried using datagrip to import a database and ran the following construct

pg_restore -d postgresql://admin:"password"@db-postgresql-nyc1-59296-do-user-12660498-0.b.db.ondigitalocean.com:25060/Megacity?sslmode=require --jobs 2 C:\Program Files\PostgreSQL\15\bin\Megacity.sql

Then the following errors popped up:

do-user-12660498-0.b.db.ondigitalocean.com:25060/defaultdb?sslmode=require
[2022-10-25 09:41:23] [42601] ERROR: syntax error at or near "-"
[2022-10-25 09:41:23] Position: 3

Please how can I resolve this?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @phetchaconsults,

I’ll urge you to check the following Docs;

https://docs.digitalocean.com/products/databases/postgresql/how-to/import-databases/

Having said that, looking at your pg_restore command everything looks to be proper.

  1. pg_restore -d postgresql://admin:"password"@db-postgresql-nyc1-59296-do-user-12660498-0.b.db.ondigitalocean.com:25060/Megacity?sslmode=require --jobs 2 C:\Program Files\PostgreSQL\15\bin\Megacity.sql

All I can think of is maybe you’ve used a symbol that’s not ‘-’ but something that looks like it. I’ll suggest to try and re-type the command to see if this error would still appear.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.