I have included gems,
dbd-mysql (0.4.4)
dbi (0.4.5)
mysql (2.8.1)
on rails console when I run the following code,
require 'rubygems'
require "dbi"
require 'dbd-mysql'
dbh = DBI.connect("DBI:Mysql:TestDB:localhost","username", "pwd")
1.9.2-p180 :001 > require 'rubygems'
=> false
1.9.2-p180 :002 > require "dbi"
=> false
1.9.2p180 :003 > require 'dbd-mysql'
LoadError: no such file to load -- dbd-mysql
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:318:in `rescue in load_driver'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:242:in `load_driver'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:160:in `_get_full_driver'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect'
from (irb):3
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.1.1/lib/rails/commands/console.rb:45:in `start'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.1.1/lib/rails/commands/console.rb:8:in `start'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.1.1/lib/rails/commands.rb:40:in `'
from script/rails:6:in `require'
from script/rails:6:in `'
1.9.2-p180 :004 > dbh = DBI.connect("DBI:Mysql:TestDB:localhost","username", "pwd")
DBI::InterfaceError: Could not load driver (uninitialized constant MysqlError)
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:318:in `rescue in load_driver'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:242:in `load_driver'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:160:in `_get_full_driver'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect'
from (irb):3
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.1.1/lib/rails/commands/console.rb:45:in `start'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.1.1/lib/rails/commands/console.rb:8:in `start'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.1.1/lib/rails/commands.rb:40:in `'
from script/rails:6:in `require'
from script/rails:6:in `'
1.9.2-p180 :004 >
Am getting this error
LoadError: no such file to load -- dbd-mysql
DBI::InterfaceError: Could not load driver (uninitialized constant MysqlError)
is my dbd-mysql gem is not installed properly?
Please some one suggest me how to resolve this issue?
解决方案
If I were you, I would create a brand new app with
rails new ProjectName -d mysql
Then I would specify the DB Name in Config/Database.yml