su - mysql cd /tmp mysqldump -q --quote-names --default-character-set=latin1 --skip-extended-insert -u root user > andrews_user.sql
su - mysql cd /tmp mysqldump -q --skip-tz-utc --default-character-set=latin1 --skip-extended-insert -u root user > moog_user.sql scp www@andrews:/tmp/andrews_user.sql .
egrep "^INSERT" andrews_user2.sql | sort > aus.sql egrep "^INSERT" moog_user.sql | sort > mus.sql diff aus.sql mus.sql > us.sql
/tmp/andrews_user.sql
and update the
table name from profiles
to
profiles_andrews
/tmp/moog_user.sql
and update the
table name from profiles
to
profiles_moog
mysqladmin create user_merge mysql user_merge < andrews_user.sql mysql user_merge < moog_user.sql
lastProfileUpdate
.
mysqladmin create user_merged
create.sql
contains
CREATE TABLE profiles_merged LIKE user.profiles; INSERT profiles_merged SELECT * FROM user.profiles;Run:
mysql user_merged < create.sql
m1.sql
REPLACE INTO profiles_merged SELECT a.* FROM profiles_andrews a, profiles_moog m WHERE a.username = m.username AND a.lastProfileUpdate > m.lastProfileUpdate;Then run
mysql user_merged < m1.sql
m2.sql
INSERT INTO profiles_merged SELECT * FROM profiles_andrews a WHERE NOT EXISTS(SELECT * FROM profiles_moog m WHERE a.username = m.username);Then run
mysql user_merged < m2.sql
user.profile
table
with the contents of the user_merged.profile_merged
.Old below here
To copy the database to a new machine, it is best to work from the nightly mysql backups located in ~www/mysqlarchive/Day
.
See ~www/php/util/copydatabase
for a script that will copy archived database files from two machines and merge them.
See ~www/php/util/mysqlmerge
for a script that then destroys the current database and loads in the new database.