How do I copy MySQL databases to another Ubuntu machine?

I installed a LAMP server on my pc and created databases. Now I want to copy it to my friend's computer. How can I do this?

1 Answer

  1. To backup/save databases as SQL files, run

    mysqldump -uroot -p database_name > dumpfilename.sql

    Replace database_name with the name of the database you want to copy over and enter the root password when asked.

  2. Copy the dumpfilename.sql file over to the other system like any other regular file and import the database using this command:

    mysql -uroot -p database_name < dumpfilename.sql

    Again, replace database_name with the (new) name of the database and enter the root password when asked.

Note that this is totally not OS-specific, but a general way of dumping/importing MySQL databases.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like