Connecting to remote Databases in Ruby DBI -


how can connect remote databases in ruby ?

i have application need connect remote host databases , read databases table , map application .

thank in advance

your question incomplete. didn't mention database. i'm assuming mysql. should show efforts.

install mysql gem http://tmtm.org/en/mysql/ruby/

gem install mysql 

now, use in ruby file.

db = mysql.new(hostname, username, password, database) 

example:

require 'mysql' db = mysql.new('209.88.228.142', 'someuser', 'exceptionalpassword', 'greatdb') 

put server's ip or host in hostname. rest of parameters self-explanatory. must allow public ip address in remote servers mysql host. example, if ip 209.88.228.142, must allow ip in mysql server.

see doc more detail.

allowing ip in database server. assuming above mentioned ip public ip, can allow access greatdb database using following command. run in db server's console.

grant on greatdb.* someuser@'209.88.228.142' identified 'exceptionalpassword'; 

note: replace username, dbname, password, host/ip appropriate values you.


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -