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!
 

windows rails new demo时候出错Make sure that `gem install mysql2 -v '0.3.15'` succeeds before bundling.,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。