Unix Technical Forum

Owner Issue When Migrating Database to New Server

This is a discussion on Owner Issue When Migrating Database to New Server within the pgsql Admins forums, part of the PostgreSQL category; --> PostgreSQL: 8.2.4 OS: Linux Red Hat 4.x 64 bit I have a database running on serverA with postgres user ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 08:06 AM
Campbell, Lance
 
Posts: n/a
Default Owner Issue When Migrating Database to New Server

PostgreSQL: 8.2.4

OS: Linux Red Hat 4.x 64 bit



I have a database running on serverA with postgres user userA. I want
to migrate the database to ServerB with a postgres user userB. Notice
the users are not the same. I did the following to put the database on
the new server:



1) I created the database on serverB with userB.

2) I then did pg_dump -h serverA -U userA dbname | psql -h serverB
-U userB dbname



This of course failed. The user userA was not in the database found on
serverB. I then did the following:



1) I created the database on serverB with userB.

2) On serverB I did pg_dump -h serverA -U userA dbname >
postgreSQL.out

3) I then did a find and replace on userA with userB through NANO
on the file postgreSQL.out

4) I then did psql -h serverB -U userB dbname -f postgreSQL.out



Is there a better way to do this?



Thanks,





Lance Campbell

Project Manager/Software Architect

Web Services at Public Affairs

University of Illinois

217.333.0382

http://webservices.uiuc.edu




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 08:06 AM
Milen A. Radev
 
Posts: n/a
Default Re: Owner Issue When Migrating Database to New Server

Campbell, Lance написа:
> PostgreSQL: 8.2.4
>
> OS: Linux Red Hat 4.x 64 bit
>
>
>
> I have a database running on serverA with postgres user userA. I want
> to migrate the database to ServerB with a postgres user userB. Notice
> the users are not the same. I did the following to put the database on
> the new server:
>
>
>
> 1) I created the database on serverB with userB.
>
> 2) I then did pg_dump -h serverA -U userA dbname | psql -h serverB
> -U userB dbname
>
>
>
> This of course failed. The user userA was not in the database found on
> serverB. I then did the following:
>
>
>
> 1) I created the database on serverB with userB.
>
> 2) On serverB I did pg_dump -h serverA -U userA dbname >
> postgreSQL.out
>
> 3) I then did a find and replace on userA with userB through NANO
> on the file postgreSQL.out
>
> 4) I then did psql -h serverB -U userB dbname -f postgreSQL.out
>
>
>
> Is there a better way to do this?
>



Yes - use the "--no-owner" option for "pg_dump" when creating the dump file.

--
Milen A. Radev


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:21 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com