HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMajor

PostgreSQL: Cannot change directory to /root

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlcannotdirectoryrootchange

Problem

I am trying to copy a table planet_osm_polygon from one database osm to another test. I su postgres and performed the pg_dump.

Problem: However I'm getting the error could not change directory to "/root" and the Password: prompt appeared twice! Is there a way to perform the pg_dump when logged in as root?

root@lalaland:~# su postgres
postgres@lalaland:/root$ pg_dump -h localhost "osm" --table "public.planet_osm_polygon" | 
    psql -h localhost "test" --table "staging.planet_osm_polygon"
could not change directory to "/root"
could not change directory to "/root"
Password: Password:


UPDATE

Problem #2: It appears that the table is copied into the public schema even though I passed the flag --table="staging.planet_osm_polygon". Why isn't it copied to schema staging?

Solution

Try this: Re: could not change directory to "/root":


Apparently you did "su postgres" from the root account, so you're
still in root's home directory. It'd be better to do "su - postgres"
to ensure you've acquired all of the postgres account's environment.
Reading "man su" might help you out here.

Context

StackExchange Database Administrators Q#40335, answer score: 34

Revisions (0)

No revisions yet.