Accessing mysql thorugh ruby

Heres the code:

# example of connecting to mysql

require "mysql"

begin

	dbName = "database"
	m = Mysql.new("localhost", "root", "password") # this line fails
	m.select_db(dbName)

	result = m.query("SELECT * FROM test")
	fields = result.fetch_fields
	fields.each do |field|
	puts field.name
	end
	gets
	m.close

end

The error: "Cant connect to MySQL server on “localhost” (10061)
(MySQL::Error)

I accessed mysql through its window with the values I use in the line
that fails, so they are correct.

Any ideas?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs