Forum: Ruby accessing mysql thorugh ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Andrew B. (Guest)
on 2006-05-05 19:03
Heres the code:

[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

[/code]

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 topic is locked and can not be replied to.