PDA

View Full Version : [ubuntu] How do I move a MySQL database to a new server?


avahi
February 5th, 2009, 08:52 PM
Hi,

My old server running Ubuntu Server 8.04 just crapped out on me :( (mobo is fried)
Whatever, that entire computer has been problematic for several months now.

I got ahold of a new computer and installed all the LAMP essentials to Ubuntu Server 8.10.

I have the old server's hard drive plugged in via an IDE enclosure.

How can I move all of the MySQL databases to the new server?
I already restored the contents of /var/www.

Thanks

mozkill
February 5th, 2009, 09:10 PM
you can restore directly from backup archives if you kept backups , then create a database of the same name, then restore from the backup file. otherwise im not sure how to do it.

you should always make backups as a regular habit, even if the backup is to the same hard drive.

R.Bucky
February 6th, 2009, 01:06 AM
You should be using Phpmyadmin or something equivalent. In Phpmyadmin, click on a database from your install, Export as .sql and save somewhere. When you are ready to reinstall, go to the Phpmyadmin homepage (e.g.http://localhost/phpmyadmin) and click import. Locate your file and upload. You may have to alter the max_upload value in your php.ini.

To change that file, type sudo gedit /etc/php5/apache2/php.ini in terminal and find the line that says something like max_upload and change it to a value that corresponds to the maximum size of your .sql file. Then restart your apache server using sudo /etc/init.d/apache2 force-reload

hyper_ch
February 6th, 2009, 06:30 AM
you can

(a) stop mysql and then copy the database binaries (they are in /var/lib/mysql)
or
(b) use mysqldump to create .sql files of your databases and then restore them