I have installed ruby(1.9.2),gem(1.8.10) and rails(3.1.0), and MYSQL is runnig on WAMP. when I try to install mysql2 0.3.7 gem(gem install mysql2 -v 0.3.7)
when run the following command it shows error
and also tired
C:/dev/Ruby192/bin/ruby.exe extconf.rb --with-mysql-lib="c:\Program File
s\MySQL\MySQL Server 5.1\lib\opt" --with-mysql-include="c:\Program Files\MySQL\M
ySQL Server 5.1\include"
but looks like i dont have \lib and \include folders in my MYSQL installed directory(in this case D:\wamp\bin\mysql\mysql5.5.8).
please help me installing the mysql gem version greater than 0.3(as I am using Rails 3.1).
Any help will aapreciated.
Thanks
Nagendra
For those cases, you should try install either mysql or mysql2 gem against MySQL Connector/C
I've written a tutorial about that:
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
Install Mysql Connector/C, it provides necessary lib and include files.
I am still having problem with mysql2 gem but below approach helped me install mysql with RoR on Windows Env.
Step 1 : Gem File changes : ({app}/Gemfile)
Update mysql2 --> mysql
Step 2 : Updates in database.yml file ({app}/config/database.yml)
Change adapter: mysql2 --> adapter: mysql
host: localhost --> host: 127.0.0.1
Step 3 : Downoad mysql-connector-c-noinstall-6.0.2-win32
Step 4 : Copy mysql-connector-c-noinstall-6.0.2-win32\lib\libmysql.dll file to C:\RailsInstaller\Ruby1.9.3\bin
Step 5 :bundle update && Start rails server
Related
I am trying to run rails server command but it showing mysql2 Load Error. I will place my Error log here
I searched many places.
I tried to install from my bundle itself using "gem install mysql2 --ruby=platform" command using connector c "libmysql.dll" file pasted in ruby/bin but no use.
I actually have MySQL installed on my system long back when I was doing JDBC connections. Its SQL server version 5.0- Is that version causing this error? Or Do I need to uninstall the MySQL from my system and install Latest Version!
And a doubt for me is how is this MySQL Server 5.0 connected to Rails as I no I have no idea about it, because while installation I used Connector C 6.1 for mysql2 installation from the Command Promt!
I tried Ruby on Rails - cannot load such file -- mysql2/2.2/mysql2 (LoadError)
I also tried Error "...cannot load such file -- mysql2/2.0/mysql2 (LoadError)". On Windows XP with Ruby 2.0.0
But I am getting the same error.
I think I have given all the details regarding versions and what I did!
I tried doing this like 50 times but no progress! I hope I will get my problem solved !Thank You!
The following below instructions can help you.
gem uninstall mysql2
Download last MySQL connector from http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip
Extract it to C:\connector-6.0.2
gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\connector-
6.0.2\lib" --with-mysql-include="C:\connector-6.0.2\include" --with-mysql-
dir="C:\connector-6.0.2"'
Or even shorter:
gem install mysql2 --platform=ruby -- --with-opt-dir="C:\connector-6.0.2"
im not using windows. but seems to be duplicate with posts like this (Error "...cannot load such file -- mysql2/2.0/mysql2 (LoadError)". On Windows XP with Ruby 2.0.0)
I try to install the mysql2 gem on Windows 7 32-bit.
I run:
gem install mysql2
and I get the following error:
ERROR: Error installing mysql2:
The 'mysql2' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
Any ideas what could cause this error, and how to solve this ?
UPDATE
I did everything as described here, but I can't figure out the last step:
gem install mysql2 --
'--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.1\lib\opt"
--with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.1\include"'
I understand that I should change the paths to the correct paths in my system, but I can't find the lib\opt and the include directories in my WAMP MySQL installation. I use WAMP 2.1.
Please advise.
Here is a proper solution for anyone interested, that doesn't mess up your current installation of mysql server -
EDIT : Make sure you download the right version on MySQL server. :
if you intend to connect to a 6.0 or 5.5 server - download those binaries. I'm connecting to mysql 5.1 - hence my example. Also keep in mind latest mysql2 gem ( v 0.3.7) was tested against mysql server 6 - hence it keeps failing to build on windows for earlier versions. also make sure you use the right libmysql.dll in your ruby folder.
Download a zip file with mysql server 5.1 NOT the msi one. Make sure it's 32-bit NOT 64-bit. (From here)
Since there is no installer file with this, create a folder c:\mysql-gem-install - you can remove it once you finish.
Extract all the files from the zip file into the folder you just created.
now run this command
gem install mysql2 -- '--with-mysql-lib="c:\mysql-gem-install\lib\opt" --with-mysql-include="c:\mysql-gem-install\include"'
I just installed mysql2 gem v. 0.3.7
EDIT 1
One more thing: make sure you run the command in Command Prompt directly. As in not PowerShell or Consol2 - for some reason if you try that it will give you and error " invalid option" - has to do with the way -- is parsed.
EDIT 2
I just was doing a blank windows 7 install and one thing I ran into is that you need to add one more step to this: check to see if there is libmysql.dll in your ruby bin directory, if not copy one over from your mysql install. It should be of the same version as your mysql2 build.
THANK YOU! One note: I had to include the --platform=ruby option as well. Thus, the final entire command line was:
gem install mysql2 --platform=ruby -- '--with-mysql-lib="c:\mysql-gem-install\lib\opt" --with-mysql-include="c:\mysql-gem-install\include"'
When I tried it without the platform=ruby option, DevKit didn't run and it just installed the normal mysql2 gem - it even gave a warning message about mysql2 being built for 6.0.2. I uninstalled it (gem uninstall mysql2), then ran it again with --platform=ruby and it worked awesome!
Me: Windows 7 64bit, Ruby 1.9.3p125, Rails 3.2.1, MySQL 5.1.56
Well, i don't really use Windows, but what about downloading the DevKit from 'http://rubyinstaller.org/downloads' and following the instructions at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit' ?
Try XAMPP from apachefriends.org, be sure to download the full version and you will find "lib", "bin", "include" and other MySQL directories. For further details, refer to -
http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html
You should execute the setup file again,and choose the modify option,then check the Developer Components.When it finish,you will found the include folder and the opt folder.
Not all mysql2 versions come with windows binaries.
Easiest way to install gem mysql2 on windows is to pick a version that includes win binaries.
Link to list of versions
Choose the latest version number that includes “x86-mingw32”
For example 0.3.11
To install it:
gem install mysql2 -v 0.3.11
or in the gemfile:
gem „mysql2“, „0.3.11“
My rails applications run on a shared host. I don't have access to a commandline and can't run the bundle command. I can run a few pre-selected rake commands.
On my development machine, I've done bundle install --deployment, so that all my gems are in vendor/bundle.
Problem is, however, that my development machine is not compatible with my shared host (32/64 bits), so the native extension of the mysql2 gem doesn't work on the shared host. The shared host does have the mysql2 gem installed, though.
If I remove 'mysql2' from the Gemfile, I get this error: !!! Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2' (<= this was because I had the adapter set to mysql instead of mysql2 in database.yml:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: db
pool: 5
username: user
password: pass
socket: /var/run/mysqld/mysqld.sock
(same for test/production)
If I keep gem 'mysql2' in my Gemfile, I get this error (which makes sense, because of the native extension was compiled on a different machine:
/home/project/vendor/bundle/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.so: wrong ELF class: ELFCLASS32 - /home/project/vendor/bundle/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.so
If I remove gem 'mysql2', I get:
Please install the mysql2 adapter: 'gem install activerecord-mysql2-adapter' (no such file to load -- active_record/connection_adapters/mysql2_adapter)
I would like to specify which gems should be loaded from my own applications vendor/bundle directory and which gems from the system gem directory.
Is this possible with bundler?
What's the best solution for this problem?
Thanks.
Check your database.yml file. Make sure you are not referring to the adapter that you don't have installed in your environment.
Have you checked your gemlock file for -x86 gem references? I had a similar issue deploying from windows xp to 64-bit ubuntu. Modify these to remove the -x86 part and run bundle install again, this should build the 64-bit native gem if all the libraries are on the instance.
My Rails server worked well through normal development scripting and I planned to use Netbeans for Rails. When I started my existing project with Netbeans and restarted my Webrick server, It shows error
RuntimeError (Please install the jdbcmysql adapter: gem install activerecord-jdbcmysql-adapter (no such file to load -- java))
I feel this error is related with JRuby, But I never using JRuby and I am using Ruby 1.9.2, Rails 3.0.0 and I dont want to use JRuby and Glassfish. I tried to remove default JRuby and Ruby1.9.2 as default, but i cant. I feel there may be a cause of linking error w.r.t JRuby. Kindly help me to rectify this issue.
Got the same error.
Look in your config/database.yml - netbeans changes the adapter automatically. Just write 'sqlite3' as adapter or whatever fits for you instead of 'jdbcmysql'.
Hope I could help!
I solved this issue, In Netbeans,,, i set Ruby 1.9.2 as default by
Project -> Right Click "My project" -> Set Configuration ->Customize -> Changed Ruby Platform as "Ruby 1.9.2" from "JRuby".
Now it works without any error. This may help for some other reader.
--
With Thanks,
Palani Kannan. K,
You didn't install the necesary gem, that's all. You need to do this: gem install activerecord-jdbcmysql-adapter to install necesary aditional gems, and then you have to edit your database.yml with the proper gem, for example:
development:
adapter: jdbcmysql
encoding: utf8
reconnect: false
database: db_development
pool: 5
username: username
password: passwrd
socket: /var/run/mysqld/mysqld.sock
Check your database.yml file you will find that tha adapter have been changed from your previous configured database to jdbcmysql.
you can delete it and write it back!
For example:
development:
adapter: jdbcmysql
and if you were using mysql
development:
adapter: mysql2
And it will works!
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
ruby mysql2 gem installation issues
I have worked with ruby on rails with mysql2 database. I have installed the the mysql2 gem in my system. I successfully configure my database my database.yml file which is
development:
adapter: mysql2
database: AddressBook
username: root
password: root
host: localhost
pool: 5
timeout: 5000`
but the issues are
When i tried to create my model using the command rails g model contact it shows an error
"Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (no such file to load -- active_record/connection_adapters/mysql2_adapter) (RuntimeError)"
like this.
So in order to install mysql2 i have execute the command gem install mysql2. It shows 1 gem installed with a message of "Enclosing class/module 'mMysql2' for class Client not known"
And one more thing, after installing mysql2 gem file if i am check the existence of mysql2 using command
which mysql2
it again shows no mysql2 is installed with a message
"/usr/bin/which: no mysql2 in (/usr/lib/ccache:/usr/lib/ccache:/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/zoondia001/bin)"
If ruby on rails database connection is not possible with mysql2 please tell me another way to connect ruby on rails to database
i am using fedora 13 and installed ruby,ruby on rails and all the gems that are needed for running. Anybody please tell me how track this problem, i am nearly spend my 48 hours for tracking this issues but not getting the solution. please help me
thanks
Add
gem 'mysql2', '< 0.3'
in gemfile
Finally it is corrected. I have remove ruby,rails and gem from system and re-install again. Any way thanks for the help