0

I am working on a Rails application in Lubuntu. It has MySQL database at the back end. I want to move the application with the Database to my new Ubuntu OS. I can move the Rails project by using Git, but I am not sure how to move the MySQL database. I was wondering if there is a quick way to move the database. I would appreciate any help.

Thanks

2 Answers 2

2

You can move the data by taking a mysqldump.

mysqldump -u [user_name] -p  -h [hostname] [database_name] > [file_name.sql]

Use this in the terminal with the relevant attributes, upon success it will generate a MySQL dump file which you can later to use to restore your database to another machine. Also since the structure of the database is remaining the same, applying migrations from rails will show no changes, then you are good to work with it in the new machine.

Sign up to request clarification or add additional context in comments.

Comments

0

Follow these steps:

1) For exporting the db dump into the local system

mysqldump -u [username] -p [db_name] > [sql_file_name.sql]

2) Make its tar for easily share with other system:

tar -czvf [any_name.tar.gz] [sql_file_name.sql]

3) Move it to the other system where you have to import it.

4) Untar the file:

tar -xzf [any_name.tar.gz]

5) Import database:

mysql -u [username] -p [db_name] < [sql_file_name.sql]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.