开发者

using mysql instead of sqlite in a rails app

开发者 https://www.devze.com 2023-02-13 14:33 出处:网络
I\'m not sure how to find what I\'m looking for here, but I\'ve cloned a rails app from someone else and they were using sqlite, how do I switch 开发者_运维问答the project over to mysql? There are no

I'm not sure how to find what I'm looking for here, but I've cloned a rails app from someone else and they were using sqlite, how do I switch 开发者_运维问答the project over to mysql? There are no migrations but it has a schema. Thanks.


Have you changed the database.yml?

eg:

development: 
  adapter: mysql
  encoding: utf8
  database: <db name here>
  pool: 5
  username: root
  password: <p/w>
  socket: /var/run/mysqld/mysqld.sock


You don't need a migration. rake db:setup (or rake db:schema:load)

EDIT: this is assuming the schema is a schema.rb file. If it's an SQL file you'll have to convert that and then just run it using the mysql client.


hope this will helps you.

If you have some errors in the Database.yml file, you might have to install the mysql gem:

gem install mysql   

Have rake create your database

rake db:create     
rake db:schema:load

Use YamlDb to reload your data into MySql

rake db:load  

You really should use db:schema:load instead of db:migrate for creating new databases

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号