# MySQL Module - Segmentation Fault - Windows

**URL:** <https://www.ruby-forum.com/t/mysql-module-segmentation-fault-windows/119962>\
**Category:** Ruby\
**Created:** [November 12, 2007, 3:36pm UTC](https://www.ruby-forum.com/t/mysql-module-segmentation-fault-windows/119962 "2007-11-12T15:36:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Venks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/edb3f5/32.png) [@Venks](https://www.ruby-forum.com/u/Venks)\
**Post date:** [November 12, 2007, 3:36pm UTC](https://www.ruby-forum.com/t/mysql-module-segmentation-fault-windows/119962/1 "2007-11-12T15:36:30Z")

</div>

Hi,

I am getting “segmentation fault” when I try to run the following  
piece of ruby code.

1. I installed the latest version of MySQL version for Windows 5.1.22
2. I installed the MySQL module using “gem install mysql” and chose  
option 1 (mysql 2.7.3. win32)

I don’t have this problem on Linux running Fedora. Unfortunately I  
really need to make this work on my laptop running windows where most  
of the development will be done.

Thanks,

-Venks

==============================================================  
#!/usr/bin/ruby -w

# Ruby script using Ruby MySQL module to test connection information

require “mysql”

begin

dbh = Mysql.real\_connect(“localhost”, “csread”, “csread”, “csapp”)

puts "Client Info: " + dbh.get\_client\_info

rescue Mysql::Error =\> e

puts “Error code: #{e.errno}”  
puts “Error message: #{e.error}”  
puts “Error SQLSTATE: #{e.sqlstate}” if e.respond\_to?(“sqlstate”)

ensure

dbh.close if dbh

# end

---

<div class="post-metadata">

**Author:** ![Venks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/edb3f5/32.png) [@Venks](https://www.ruby-forum.com/u/Venks)\
**Post date:** [November 12, 2007, 5:45pm UTC](https://www.ruby-forum.com/t/mysql-module-segmentation-fault-windows/119962/2 "2007-11-12T17:45:29Z")

</div>

On Nov 12, 11:35 am, Venks [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> really need to make this work on my laptop running windows where most  
> of the development will be done.

Did you run the same MySQL version under Fedora?

I didn’t updated to latest beta (5.1) of MySQL, this is my result:

D:\Users\Developer\Desktop\>ruby -w db\_test.rb  
Client Info: 5.0.45  
Error in my\_thread\_global\_end(): 1 threads didn’t exit

5.1 is flagged as Release Candidate / Development Release. Maybe the  
mysql-ruby bindings need to be tweaked for making this compatible.

Since mswin32 extensions need VC6, do you have the compiler available  
to build from source?

---

<div class="post-metadata">

**Author:** ![Venks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/edb3f5/32.png) [@Venks](https://www.ruby-forum.com/u/Venks)\
**Post date:** [November 12, 2007, 5:59pm UTC](https://www.ruby-forum.com/t/mysql-module-segmentation-fault-windows/119962/3 "2007-11-12T17:59:32Z")

</div>

No. I don’t have the compiler and I can confirm that this is becuase  
of MySQL 5.1.

When I install MySQL 5.0 on my laptop, things work fine.

---

<div class="post-metadata">

**Author:** ![Venks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/edb3f5/32.png) [@Venks](https://www.ruby-forum.com/u/Venks)\
**Post date:** [December 17, 2007, 6:31am UTC](https://www.ruby-forum.com/t/mysql-module-segmentation-fault-windows/119962/4 "2007-12-17T06:31:24Z")

</div>

Venks wrote:

> Hi,
> 
> I am getting “segmentation fault” when I try to run the following  
> piece of ruby code.
> 
> 1. I installed the latest version of MySQL version for Windows 5.1.22
> 2. I installed the MySQL module using “gem install mysql” and chose  
> option 1 (mysql 2.7.3. win32)
> 
> I don’t have this problem on Linux running Fedora. Unfortunately I  
> really need to make this work on my laptop running windows where most  
> of the development will be done.
> 
> Thanks,
> 
> -Venks

I am having the same issue, although with MySQL version 5.0.45.  
The steps I followed were as followed:

1. Download “mysql-5.0.45-win32.zip” from the MySQL community server 5.0  
downloads page
2. Extract and run the contained “Setup.exe”
3. Perform installation of MySQL 5.0.45
4. Install mysql 2.7.3 win32 using “gem install mysql”
5. Run “irb” and try “require ‘mysql’”

Each time I get:  
c:/ruby/lib/ruby/site\_ruby/1.8/i386-msvcrt/mysql.so: [BUG] Segmentation  
fault  
ruby 1.8.6 (2007-03-13) [i386-mswin32]

Venks wrote:

> No. I don’t have the compiler and I can confirm that this is becuase  
> of MySQL 5.1.
> 
> When I install MySQL 5.0 on my laptop, things work fine.

I was wondering which specific version of MySQL 5.0 you used and whether  
you installed any other software to help get this to work.

I have tried trawling through Google but the answers to  
Windows/MySQL/Ruby seem to be scattered and many are for older versions  
of Ruby.

Thanks,  
Danny
