0

I'm trying to connect to a SQL server in a domain, but I don't know why I have an error.

My environnement is Ubuntu 14.04, and I use mysql2. I think my problem is :server="myServer" but I have to specify what server.

My request is :

db = Mysql2::Client.new(:host => "xxx.xxx.xxx.xxx",:server="myServer" ,:username => "myname", :password => "SECRET", :port => 3306, :database => "test" )

which gives me this error: Mysql2::error (111)

This request is working:

db = Mysql2::Client.new(:host => "192.168.1.1", :username => "root", :password => "SECRET", :port => 3306, :database => "test" )
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Skunk
  • 85
  • 1
  • 11
  • 1
    Using the `Mysql2` driver directly is probably a bad plan. What are you trying to do? A layer like [Sequel](http://sequel.jeremyevans.net/) helps considerably when interacting with a database. – tadman Nov 21 '14 at 15:39
  • @tadman, +1. I agree about Sequel. It's a great way to go when talking to a database. Look at the Sequel [home page](http://sequel.jeremyevans.net/), [README](http://sequel.jeremyevans.net/rdoc/files/README_rdoc.html) and [cheatsheet](http://sequel.jeremyevans.net/rdoc/files/doc/cheat_sheet_rdoc.html) to get an idea of how it can make life a lot easier. – the Tin Man Nov 21 '14 at 16:58
  • Are you trying to connect to a MySQL SQL-based server, or a MS "SQL Server"? It looks like you're trying to connect to a MS SQL Server, so why are you using the mysql2 gem? – the Tin Man Nov 21 '14 at 17:02

1 Answers1

0

Take a look at this: Can't connect to MySQL server error 111

Probably you are facing the same issue.

Community
  • 1
  • 1
Josué Lima
  • 483
  • 6
  • 18
  • Did you try connecting through your terminal? Without using mysql2 gem? (mysql --host=localhost --user=myname --password mydb) If so, there were any errors? – Josué Lima Nov 21 '14 at 14:52