patternsqlMinor
Moving large databases
Viewed 0 times
largemovingdatabases
Problem
I have a centos server and /var/lib/mysql/ is 125GB (disk has 1GB free space).
Ordinarily I would use mysqldump to backup the databases, but I don't normally work with such large databases, so I need to know the safest way of copying the databases over to a new server.
All advice appreciated!
Ordinarily I would use mysqldump to backup the databases, but I don't normally work with such large databases, so I need to know the safest way of copying the databases over to a new server.
All advice appreciated!
Solution
You can use following steps
On old Server
1.Stop mysql server
2.Copy contents of datadir to another location on disk as ... mysqlbackup
3.Start mysql server again
4.Compress the data (tar -czvf mysqlbackup.tar.gz mysqlbackup)
5.Copy the compressed file to new server
On New Server
1.Install MySQL MySQL version should be same as of old server
2.Unzip compressed file (tar -xzvf mysqlbackup.tar.gz)
3.Move contents of mysqlbackup to the datadir.
4.Make sure that permissions of datadir are correct
5.Make sure your innodb_log_file_size is same on new server, or if it's not, don't copy the old log files (MySQL will generate these)
6.Start MySQL.
You can also look at How can I move a database from one server to another?
On old Server
1.Stop mysql server
2.Copy contents of datadir to another location on disk as ... mysqlbackup
3.Start mysql server again
4.Compress the data (tar -czvf mysqlbackup.tar.gz mysqlbackup)
5.Copy the compressed file to new server
On New Server
1.Install MySQL MySQL version should be same as of old server
2.Unzip compressed file (tar -xzvf mysqlbackup.tar.gz)
3.Move contents of mysqlbackup to the datadir.
4.Make sure that permissions of datadir are correct
5.Make sure your innodb_log_file_size is same on new server, or if it's not, don't copy the old log files (MySQL will generate these)
6.Start MySQL.
You can also look at How can I move a database from one server to another?
Context
StackExchange Database Administrators Q#46715, answer score: 3
Revisions (0)
No revisions yet.