2013-04-16 35 views
5

mam włączone perełki,DBI :: InterfaceError: Nie można załadować sterownika (niezainicjowanymi stała MysqlError)

dbd-mysql (0.4.4) 
dbi (0.4.5) 
mysql (2.8.1) 

na konsoli szyn kiedy uruchomić poniższy kod,

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 > 

otrzymuję ten błąd

LoadError: no such file to load -- dbd-mysql 
DBI::InterfaceError: Could not load driver (uninitialized constant MysqlError) 

to mój klejnot dbd-mysql nie jest zainstalowany prawidłowo? Proszę, ktoś mi sugeruje, jak rozwiązać ten problem?

+0

Czy trzeba wymagać '„mysql'' ? –

+0

Właściwie to nowość, więc śledzę blogi. W tym celu również wymagali mysql. Więc nie jestem pewien, czy jest to potrzebne, czy nie – Ashwini

Odpowiedz

0

If I were you, chciałbym stworzyć nową aplikację z

rails new ProjectName -d mysql 

Następnie chciałbym podać nazwę DB w config/database.yml