windows rails new demo时候出错Make sure that `gem install mysql2 -v '0.3.15'` succeeds before bundling.
rails new demo --database=mysql最后报错
Gem files will remain installed in D:/BillFiles/rails_dev/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.15 for inspection.
Results logged to D:/BillFiles/rails_dev/Ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/mysql2-0.3.15/gem_make.out
An error occurred while installing mysql2 (0.3.15), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.15'` succeeds before bundling.
但是执行这句话后还是报错,这说明是驱动出问题
然后看到这篇文章http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
最后发现自己的ruby193是32位,mysql是64位,这样ruby就连接不上了,所以下载32位的mysql驱动http://dev.mysql.com/downloads/connector/c/
选择32位zip,解压后放在c盘根目录,重命名为mysql-connector-c-noinstall-6.0.2-win32
gem install mysql2 -- --with-mysql-lib="c:\mysql-connector-c-noinstall-6.0.2-win32\lib" --with-mysql-include="c:\mysql-connector-c-noinstall-6.0.2-win32\include" --with-mysql-dir="c:\mysql-connector-c-noinstall-6.0.2-win32"
最后把其中lib目录中的
mysql-connector-c-noinstall-6.0.2-win32\lib中的
libmysql.dll拷贝到ruby下面的bin目录
终于OK!
收获不会与付出成反比
by juandx