无法初始化mysql驱动程序,DBI :: InterfaceError:无法加载驱动程序(未初始化的常量MysqlError)...

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值