Search code examples
postgresqlwindowspsql

How to import a SQL file on PostgreSQL 16?


I have a problem when I try to import a file to PostgreSQL.

I'm using Postgresql 16.3 on Windows but whenever I try to import a new file (.sql) it doesn't work! My process on Postbird: File -> Import .sql file -> I select my sql file -> Import database -> Error! And it shows me an error that says:

" Import Options Importing File:
C:\Users\aorla\Downloads\TheBestOfBaseballAwards\baseball_dataset.sql
Select database 'baseball' psql: authentication method 10 not supported FAILURE "

The error on Postbird

I even tried some other methods, like going to SQL shell directly and try it from there using: "\i C:\Users\aorla\Downloads\TheBestOfBaseballAwards\baseball_dataset.sql" but it threw me an error again, saying:

"C:: Permission denied".

I was expecting that this would solve the problem but it didn't.

Then, I also tried from cmd using this command:

psql --host=localhost --port=5432 --dbname=baseball --username=postgres --files=C:\\Users\\aorla\\Downloads\\TheBestOfBaseballAwards\\baseball_dataset.sql

And it's error:

psql: illegal option -- files=C:\Users\aorla\Downloads\TheBestOfBaseballAwards\baseball_dataset.sql psql: hint: Try "psql --help" for more information."


Solution

  • You have a typo in psql command

    --files ❌ it will be --file

    psql --host=localhost --port=5432 --dbname=baseball --username=postgres --file=C:\\Users\\aorla\\Downloads\\TheBestOfBaseballAwards\\baseball_dataset.sql