简体   繁体   中英

ruby on rails + xampp + mysql (windows 7)

I am trying to use the mysql package included in xampp with ruby on rails on windows 7, but cannot seem to get them to work together.

I have rails 3.0.0 and xampp 1.7.3

rails works with sqlite within xampp just fine, but when attempting to use mysql via "rails new project -d mysql; cd project; bundle install"

I get the following:

Installing mysql2 (0.2.4) with native extensions C:/xampp/Ruby192/lib/ruby/1.9.1
/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Fail
ed to build gem native extension. (Gem::Installer::ExtensionBuildError)

C:/xampp/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Am I missing anything? All the posts about this issue tell me to use gem install mysql -- --with-mysql-config=PATH, but this does not seem to work with Windows, as I get the same error regardless.

And if it's just not possible, are there any drawbacks to using sqlite now, then trying to migrate the databse over to mysql (or another more robust database) later?

Did you install the mysql gem?

gem install mysql

After this you need to go to the mysql\\bin directory in your XAMPP folder and copy the

libmysql.dll

into your ruby\\bin folder.

Give it a try and let me know if it works. Also if your MySql version is 5.1 you may need to download a 5.0 version of the same dll.

gem install mysql --no-rdoc --no-ri -- '--with-mysql-lib="D:\xampp\mysql\lib" --with-mysql-include="D:\xampp\mysql\include"'

我将此代码用于mysql解决方案,这是将mysql用于xampp的正确方法。

I once had a similar issue. The important things i noted was that i already have mysql installed for usage via xampp. Firstly, you should make sure that the mysql installation is accessible from cmd by typing

    mysql --version

If it gives you a reply of our installation then you're good to go to the next step else copy the mysql bin directory and save it in your user environment variable called PATH. This should allow you to run the cmd code above fruitfully. Next Step: run (on cmd)

    gem install mysql2 --no-rdoc --no-ri

This worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM