How to do it? Opened the command line " С:\Program and Files\PostgreSQL\8.4\bin\psql.exe ", but I don’t remember anything further, I С:\Program and Files\PostgreSQL\8.4\bin\psql.exe something in my memory, the user name postgres is the name of the dump db.sql <and then I don’t remember.

    3 answers 3

    1. On good, first remove the target database, even if there is none - to be safe from errors in the process is necessary.

      Immediately for an explanation:

      -h is the server address,
      -p is the port
      -U is the username. A password will be requested for subsequent actions.
      -e - specify the name of the database
      -E is a base encoding, it is found in both UTF8 and CP1251,
      -O - the owner of the database
      -i - display all messages in the database import process,
      -d - specify the base for import,
      -v - specify the dump file

      "C:\\Program Files\\PostgreSQL\\8.4\\bin\\dropdb.exe" -h localhost -p 5432 -U postgres -e ВашаБаза

    2. Then create an empty target database:

      "C:\\Program Files\\PostgreSQL\8.4\\bin\\createdb.exe" -h localhost -p 5432 -U postgres -E UTF8 -O postgres ВашаБаза

    3. Well, import the dump:

      "C:\\Program Files\\PostgreSQL\\8.4\\bin\\pg_restore.exe" -i -h localhost -p 5432 -U postgres -d ВашаБаза -v "d:\\backup.backup"

       psql dbname < db.sql 

      See the documentation for more info http://www.postgresql.org/docs/8.1/static/backup.html

      • Ok, I read it, tried it with \ i is also normal, but it turns out I have a password on my base) - Goldy

      pgdump and pgrestore