I installed MySQL 5.5 ( mysql-installer-5.5.15.0.msi ) and mysql gem (
with “gem install mysql” command ) . Now I write a simple program ( from
this website : http://rubylearning.com/blog/2007/05/14/ruby-mysql-tutorial/ ) and when
I run it ruby give me this message :
“C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require’: 126: The specified module could not be found. -
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/1.9/mysql_api.so
(LoadError)”
I installed MySQL 5.5 ( mysql-installer-5.5.15.0.msi ) and mysql gem (
with “gem install mysql” command )
“C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require’: 126: The specified module could not be found. -
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/1.9/mysql_api.so
(LoadError)”
judging from the error it looks like mysql was not installed
properly… maybe you’re missing dependencies? try:
“gem install -r mysql”
…which should also install any dependencies you are missing.
…once you get mysql installed properly, i imagine you’ll want to
change this line. the pound sign ("#") makes it a comment, and
therefore the variable “my” is never defined, it should probably look
like this:
my = Mysql.new(hostname, username, password, databasename)
…you’ll also have to define all of those variables (hostname,
username, password, databasename,) otherwise it’s going nowhere!
Looks to me, you’re installing mysql gem successfully, but not the
build mysql_api successfully.
While installing mysql, you will need to provide mysql lib or mysql
dir, to help gem to build your mysql_api.so
While using gem install mysql, gem usually hides this error.
To fix this, I suggest you download a ruby-mysql-2.8.1.tar.gz source
code.
$ gem uninstall mysql
$ gem list --local # see mysql uninstalled
$ tar xvzf ruby-mysql-2.8.1.gz
$ ruby ext-conf.rb
$ make
$ make install
This is the exact step gem use to install mysql on your machine, but
by doing this step by step, you will see what’s going wrong.
If you need to provide mysql lib or mysql dir during install, you are
doing the right thing.
I am in Winows 7 and I think these commands are in Linux.
They will work if you have DevKit installed. You’ll need DevKit to
install gems that require building C extensions.
The mysql gem isn’t maintained anymore, AFAIK. If that matters to you,
you might want to try the mysql2 gem. There is also a gem called
ruby-mysql by the author of the mysql gem, written in 100% Ruby, so it
doesn’t need compilation.
I installed MySQL 5.5 ( mysql-installer-5.5.15.0.msi ) and mysql gem (
with “gem install mysql” command ) . Now I write a simple program ( from
this website : http://rubylearning.com/blog/2007/05/14/ruby-mysql-tutorial/ ) and when
I run it ruby give me this message :
“C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require’: 126: The specified module could not be found. -
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/1.9/mysql_api.so
(LoadError)”
The problem lies in the incompatibility of the mysql gem (binary
version) and the installed MySQL.
When you do “gem install mysql” it prints out some notes about this.
To solve this, please follow the instructions on this blog post: