changing database from PostgreSQL to MySQL in a Ruby on Rails app

风流意气都作罢 提交于 2020-01-02 07:01:12

问题


In my current application i am using PostgreSQL Data base,

but I want to change the PostgreSQL database into MYSQL DB.

if it's impossible ?


回答1:


Step 1

Make a backup copy of your data

For Rails 3, install the YAML DB gem: https://github.com/ludicast/yaml_db

For Rails 2.x install the YAML DB plugin:

script/plugin install git://github.com/adamwiggins/yaml_db.git

Run the dump task

rake db:dump

Step 2

Update your config/database.yml file.

Step 3 :

gem install mysql

Have rake create your database

rake db:create

rake db:schema:load

Step 4

Use YamlDb to reload your data into MySql

rake db:load




回答2:


this is a duplicate

Migrate database from Postgres to MySQL

dont forget to change the gems and your database config file to something like this:

development:
  adapter: mysql2
  encoding: utf8
  database: my_db_name
  username: root
  password: my_password
  host: 127.0.0.1
  port: 3306


来源:https://stackoverflow.com/questions/24237034/changing-database-from-postgresql-to-mysql-in-a-ruby-on-rails-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!