This is driving me farking insane.
I'm trying to create a simple beginner app utilizing ActiveRecord to do simple database tasks. I'm NOT using rails.
I keep getting the error:
RuntimeError: Please install the mysql adapter: `gem install activerecord-mysql-adapter` (Could not find mysql (~> 2.8.1) amongst [actionmailer-3.1.3, actionpack-3.1.3, activemodel-3.1.3, activerecord-3.1.3, activerecord-sqlserver-adapter-3.1.4, activeresource-3.1.3, activesupport-3.1.3, ansi-1.4.1, arel-2.2.1, bigdecimal-1.1.0, builder-3.0.0, bundler-1.0.21, capistrano-2.9.0, coffee-rails-3.1.1, coffee-script-2.2.0, coffee-script-source-1.1.3, daemons-1.1.4, erubis-2.7.0, eventmachine-0.12.10, execjs-1.2.9, highline-1.6.8, hike-1.2.1, hpricot-0.8.5, i18n-0.6.0, io-console-0.3, jquery-rails-1.0.19, json-1.6.3, mail-2.3.0, mime-types-1.17.2, minitest-2.5.1, multi_json-1.0.4, net-scp-1.0.4, net-sftp-2.0.5, net-ssh-2.2.1, net-ssh-gateway-1.1.0, nokogiri-1.5.0, polyglot-0.3.3, rack-1.3.5, rack-cache-1.1, rack-mount-0.8.3, rack-protection-1.1.4, rack-ssl-1.3.2, rack-test-0.6.1, rails-3.1.3, railties-3.1.3, rake-0.9.2.2, rdoc-3.11, rockhands-0.0.6, sass-3.1.11, sass-rails-3.1.5, shotgun-0.9, sinatra-1.3.1, sprockets-2.0.3, sqlite3-1.3.4, thin-1.3.1, thor-0.14.6, tilt-1.3.3, treetop-1.4.10, turn-0.8.3, tzinfo-0.3.31, uglifier-1.1.0])
This gem obviously doesn't exist on rubygems, or this would be easy...
How else am I supposed to do this?
Heres the important part
ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:host => 'localhost',
:database => 'test',
:username => 'root',
:password => 'password'
)
I can see whatever I change :adapter to in the hash is what it inserts into the error 'gem install activerecord-yousuck-adapter'
I've read just about every guide on google I can find...... at my wits end. I thought this would be at least a little easier.... I've spent hours and hours just fixing gem errors. Days in fact, and I have yet to write any actual ruby code. how frustrating.
Not sure if this is your problem but try using the adapter: mysql2
driver. It's the recommended anyway since it's way faster than the standard mysql
one.
Do you still get the same issue?
After hours of fighting with this issue, Tallboy's answer worked for me on OS X:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
Unfortunately his answer was hidden in one of the comments above; you have to click the link to expand the comment. I was getting the error message "undefined method 'init' for Mysql:Class"
I issued bundle install command, which didn't resolve the issue
I found the gemfile located in c:\Sites\<>\Gemfile
Added gem 'mysql' to the file by editing it in notepad++
Then checked whether Mysql is avilable in the bundle using bundle show mysql
After which when i issued rake db:create , I got specified file could not be found error which is was referring to libmysql.dll
You can find the same in your mysql installation or you can download from the link http://www.vertstudios.com/blog/libmysqldll-32-bit-download/
Copy that file to the Ruby directory bin folder. In My case I was using rubyinstaller so it was C:\RailsInstaller\Ruby1.9.3\bin
Voila. That's done.
^Note that the download link might lead to an incorrect library version. In which case, it's best to follow the link given in the message you get right after installing the mysql(2) gem to get the correct library version, otherwise it still won't work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With