I am having Ubuntu 14.04 desktop in which i develop software. Due to some reasons my hard disk has developed many bad sectors. I want to move my mysql server software and all the databases to a new machine. How should i do it? Somebody please help me.
Easiest way is probably to install Ubuntu 14.04 on the new system including mysql-server packages you already have installed on the old system; use
dpkg -l mysql\* to show what those packages are (make your terminal wide enough first to not truncate columns). Ensure the new system has the same or newer versions (not older versions).
Now stop mysql on old and new systems. You can now copy over the
/var/lib/mysql directory including contents; I usually use rsync for that:
# rsync -ai /var/lib/mysql/ newsystem:/var/lib/mysql/
You can also use
tar to collect all the files first and copy the tarfile, as getting
rsync to work with root might be a bit of a challenge:
# cd /var/lib; tar cvf /var/tmp/mysql-files.tar mysql/ # scp /var/tmp/mysql-files.tar newsystem:/var/tmp
On new system:
# cd /var/lib; mv mysql mysql.orig # tar xvf /var/tmp/mysql-files.tar
You may want to copy
/etc/mysql/ including contents in the same way.
Now start mysql again and everything should work.