0

I have the following problem:

I'm trying to connect to a mysql database on my remote host. I use the following ruby code

  client  = Mysql2::Client.new(:host => HOST, :username => USER, :password => PASS)

But what I am getting is:

  Mysql2::Error:
  Can't connect to MySQL server on HOST (4)

I can connect to the host from the command line, using

  mysql -u USER -p -h HOST

I can also connect with the command above (client = Mysql2::...) to the DB, that runs in VirtualBox.

What am I missing? Thanks!

CDub
  • 13,146
  • 4
  • 51
  • 68
jenia
  • 55
  • 6

1 Answers1

0

In this statement:

I can also connect with the command above (client = Mysql2::...) to the DB, that runs in VirtualBox.

Are you saying you can connect in Ruby on the VirtualBox machine that is actually running the database? If so, you're looking at firewall issues, or MySQL isn't configured to allow remote connections.

Community
  • 1
  • 1
Nick Veys
  • 23,458
  • 4
  • 47
  • 64
  • yes, i can connect to DB, running on virtualBox. I can also connect to the DB on host, using mysql -u USER -p -h HOST. So, i think, mysql is configured correctly – jenia Dec 05 '13 at 15:31