Ubuntu: Migrate all mysql databases from one server to another

  1. On the new server, install mysql server:
    sudo apt-get install mysql-server mysql-client
  2. On the new server, stop the mysql server:
    sudo service mysql stop
  3. On the new server, backup /var/lib/mysql:
    sudo mv /var/lib/mysql /var/lib/mysql.bak
  4. On the old server, stop the mysql server:
    sudo /etc/init.d/mysql stop
  5. On the new server, mirror /var/lib/mysql directory from the old server:
    sudo rsync -avz root@old_server:/var/lib/mysql /var/lib/
  6. On the new server, run
    sudo mysql_upgrade -u root -p
    (NOTE: if you forget the root user password, you can reset the root password.)
  7. Start mysql server on the new server:
    sudo service mysql start

See also

No comments:

Post a Comment