aebian

Who am I?

Musician, Programmer, Linux Geek and what not.  more...


The Categories



Stuff

Arma CodeList
GitHub Projects
Media (Gallery)
Privacy Policy
My Hardware
My Wishlist


November 21st at 10:00am
Report a website issue
For best viewing experience use a 4k screen.

nethavn Logo

❬ Back to Blog


Migrate existing MySQL Database to another server


Switching db servers and need to move your MySQL instances along? Here's how.

Hi folks,

this small post will cover how you can take your MySQL instances to another server.

What do you need?

  • MySQL Server on the new host (mariadb-server-*)
  • MySQL Server on the old host (mariadb-server-*)
  • access via shell (ssh or direct)

First you connect to your old server and stop the MySQL instance. Then you run the following code:

mysqldump --all-databases --skip-extended-insert --order-by-primary -u root -p > oldserver.sql
It will ask your for the MySQL root password. Once entered it will create a file called "oldserver.sql".

Once that done copy the sql file to your new server and login into the db via sudo mysql -u root -p and enter your password.
Once connected use the keyword source to source your SQL file. This will import the database to your new server.

Make sure your connection is stable as the import can take very long depending on the size of your old database. Once the import has finished your database should be fully restored on the new host.

That's it!

Regards,

Aebian