Accessing mysql thorugh ruby


#1

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?