How may I copy all my existing application Data fr

2019-09-15 18:48发布

问题:

This question already has an answer here:

  • Convert a Ruby on Rails app from sqlite to MySQL? 5 answers

I am working on a project in Rails 4. I was using sqlite3 database previously. But now I want to switch the database from sqlite3 to mysql. But all my previous application data should be copied so when I use mysql database none of my table data may be deleted.

回答1:

try this

1. cd /path/to/rails_app/db

2. sqlite3 DATA-BASE-NAME .dump > database.sql

3. mysql -u username -p -h localhost DATA-BASE-NAME < database.sql

Hope it will help you.