5
我已經包括寶石,DBI :: InterfaceError:無法加載驅動程序(未初始化常量了MySqlError)
dbd-mysql (0.4.4)
dbi (0.4.5)
mysql (2.8.1)
當我運行下面的代碼軌控制檯上,
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/[email protected]/gems/dbi-0.4.5/lib/dbi.rb:318:in `rescue in load_driver'
from /.rvm/gems/[email protected]/gems/dbi-0.4.5/lib/dbi.rb:242:in `load_driver'
from /.rvm/gems/[email protected]/gems/dbi-0.4.5/lib/dbi.rb:160:in `_get_full_driver'
from /.rvm/gems/[email protected]/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect'
from (irb):3
from /.rvm/gems/[email protected]/gems/railties-3.1.1/lib/rails/commands/console.rb:45:in `start'
from /.rvm/gems/[email protected]/gems/railties-3.1.1/lib/rails/commands/console.rb:8:in `start'
from /.rvm/gems/[email protected]/gems/railties-3.1.1/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
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/[email protected]/gems/dbi-0.4.5/lib/dbi.rb:318:in `rescue in load_driver'
from /.rvm/gems/[email protected]/gems/dbi-0.4.5/lib/dbi.rb:242:in `load_driver'
from /.rvm/gems/[email protected]/gems/dbi-0.4.5/lib/dbi.rb:160:in `_get_full_driver'
from /.rvm/gems/[email protected]/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect'
from (irb):3
from /.rvm/gems/[email protected]/gems/railties-3.1.1/lib/rails/commands/console.rb:45:in `start'
from /.rvm/gems/[email protected]/gems/railties-3.1.1/lib/rails/commands/console.rb:8:in `start'
from /.rvm/gems/[email protected]/gems/railties-3.1.1/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
1.9.2-p180 :004 >
正在此錯誤
LoadError: no such file to load -- dbd-mysql
DBI::InterfaceError: Could not load driver (uninitialized constant MysqlError)
是我的dbd-mysql gem安裝不正確? 請有人建議我如何解決這個問題?
你需要'需要「mysql'' ? –
其實我對這個很陌生,所以只關注博客。因爲他們也需要mysql。所以不確定是否需要 – Ashwini