7

I use pg_restore on Windows 10 with a dump file made on Linux.

I get this error

I search on the web but I don't find answer.

[NEW] : I install Ubuntu on my computer to use pg_restore but when I send

pg_restore -d mydatabase /home/user/Documents/dumpfile.dump

the command line is blocked.

Someone has this issue ?

riwanab
  • 245
  • 2
  • 4
  • 10

2 Answers2

4

Your new ubuntu installation hasn't defined the en_US.UTF-8 locale yet. So, when you're trying to restore the dumpfile, the dumpfile attempts to do something like:

CREATE DATABASE <database> WITH TEMPLATE = ... LC_COLLATE = 'en_US.UTF-8'...

But, 'en_US.UTF-8' is not defined by your new ubuntu server. First, you can verify this:

# list all "known" locales. In my case, on new Ubuntu 20, I get:
$ locale -a
C
C.UTF-8
POSIX

Edit existing /etc/locale.gen file, which contains the list of possible locales. Most locales will be commented out. These will not be defined, so, un-comment the line with 'en_US.UTF-8'.

Run (as root) locale-gen.

root# locale-gen
Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.

Notice it's now a configured locale:

$ locale -a
C
C.UTF-8
POSIX
en_US.utf8

(Yes, it is lower case utf8, not a problem)

Restart your postgres server (so it sees the new locale -- you do not need to restart the ubuntu server itself), and you restore show now work.

pbuck
  • 4,291
  • 2
  • 24
  • 36
-3

You will need to do some research on locales. The place to start is the documentation.

Postgres relies on the operating system for locale information. The names differ between Posix and Windows. Presumably, the simplest solution is to change the name somehow. There might be a way to get Windows to understand the Posix names.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • This might be of help: [Windows Locale names](https://msdn.microsoft.com/en-us/library/windows/desktop/dd373814(v=vs.85).aspx), although some names like 'Spanish_Spain.1252', which are *not* two-letter codes, and are *not* dash separated (but underscore separated) , and 1252 (meaning Windows-1252 *encoding*) are commonly found. – joanolo Feb 05 '17 at 12:03