# TypeError in using MySQL driver

**URL:** <https://www.ruby-forum.com/t/typeerror-in-using-mysql-driver/168428>\
**Category:** Ruby\
**Created:** [May 20, 2009, 7:04pm UTC](https://www.ruby-forum.com/t/typeerror-in-using-mysql-driver/168428 "2009-05-20T19:04:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bellani](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/96bed5/32.png) [@bellani](https://www.ruby-forum.com/u/bellani)\
**Post date:** [May 20, 2009, 7:04pm UTC](https://www.ruby-forum.com/t/typeerror-in-using-mysql-driver/168428/1 "2009-05-20T19:04:36Z")

</div>

I get a ‘TypeError’ when I run the following script:

require ‘dbi’  
dbi = DBI.connect(‘DBI:Mysql:wrdb\_development’, ‘root’, ‘’) do |dbh|  
end

C:/Rails/InstantRails/ruby/lib/ruby/site\_ruby/1.8/dbi/dbi.rb:501:in  
`load\_driver’: is not a class/module (TypeError)

This after installing the following gems:  
mysql-2.7.3-mswin32  
dbd-mysql-0.4.2  
dbi-0.4.1  
deprecated-2.0.1

I am running InstantRails in WinXP

I’ve searched all over and the solutions I’ve found have not fixed this  
problem.  
I did notice that installing the above gems did not create MySQL driver  
directories in  
C:/Rails/InstantRails/ruby/lib/ruby/site\_ruby/1.8/DBD/

I only see ‘ODBC’ and ‘Proxy’ directories.

Are there additional setup scripts I need to run?

---

<div class="post-metadata">

**Author:** ![bellani](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/96bed5/32.png) [@bellani](https://www.ruby-forum.com/u/bellani)\
**Post date:** [May 20, 2009, 11:30pm UTC](https://www.ruby-forum.com/t/typeerror-in-using-mysql-driver/168428/2 "2009-05-20T23:30:49Z")

</div>

This did the trick for me:

1. Downloaded dbi-04.1.zip then expanded it in a temp directory

2. Ran the following scripts in the temp directory:  
2.a ruby setup.rb config  
2.b ruby setup.rb setup  
2.c ruby setup.rb install

These steps created additional files in the  
\ruby\lib\ruby\site\_ruby\1.8\dbi directory which were not generated when  
I first installed the dbi-0.4.1 gem

These commands now work:

require ‘dbi’  
dbi = DBI.connect(‘DBI:Mysql:wrdb\_development’, ‘root’, ‘’) do |dbh|  
sth = dbh.prepare(‘select \* from testtable’)  
sth.execute

# Print out each row

while row=sth.fetch do  
p row  
end  
end

Hopefully with this out of the way, I’d be able to run stored procedures  
as well.

Ed Bayudan wrote:

> I get a ‘TypeError’ when I run the following script:
> 
> require ‘dbi’  
> dbi = DBI.connect(‘DBI:Mysql:wrdb\_development’, ‘root’, ‘’) do |dbh|  
> end
> 
> C:/Rails/InstantRails/ruby/lib/ruby/site\_ruby/1.8/dbi/dbi.rb:501:in  
> `load\_driver’: is not a class/module (TypeError)
> 
> This after installing the following gems:  
> mysql-2.7.3-mswin32  
> dbd-mysql-0.4.2  
> dbi-0.4.1  
> deprecated-2.0.1
> 
> I am running InstantRails in WinXP
> 
> I’ve searched all over and the solutions I’ve found have not fixed this  
> problem.  
> I did notice that installing the above gems did not create MySQL driver  
> directories in  
> C:/Rails/InstantRails/ruby/lib/ruby/site\_ruby/1.8/DBD/
> 
> I only see ‘ODBC’ and ‘Proxy’ directories.
> 
> Are there additional setup scripts I need to run?
