rails new blog 创建项目,修改config/database.yml
development: adapter: mysql2 encoding: utf8 reconnect: false database: blog_development pool: 5 username: dbuser password: dbuser host: localhost |
cd blog进入项目目录
rake db:create 命令出现报错:
F:\Ruby\blog>rake db:migrate rake aborted! Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (my sql2 is not part of the bundle. Add it to Gemfile.) Tasks: TOP => db:migrate => db:load_config (See full trace by running task with --trace) |
搜索找到原因:新建项目是用 rails new blog -d mysql 重建项目立马解决。(或者编辑项目下Gemfile文件)
接着 rake db:create 命令,仍然报错:
F:\Ruby\blog>rake db:migrate rake aborted! Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the client library is 5.5.9. (See full trace by running task with --trace) |
When run rails server,get the error(already install newest RailsInstaller of windows xp and mysql2-0.3.11-x86-mingw32) : d:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the client library is 5.0.16. (RuntimeError)...... There is a easy way to let RailsInstaller(Ruby1.9.2) use mysql-connector-c-6.(1)download mysql-connector-c-noinstall-6.0.2-win32.zip Then run rails server,every thing is ok. |
mysql-connector-c-noinstall-6.0.2-win32.zip
下载后 解压把lib目录里的 libmysql.dll复制到 ruby/bin目录。再rake,问题解决。