D
Dave Lilley
I have been given a job to put a local mysql to a remote server and then
connect to it.
the thing is I've not done it before and am hitting an obstacle to make
this work.
1. it isn't a web server so you don't go http://example.com it is simply
example.com USERNAME PASSWORD (once access is granted you can then
connect to the mysql as you normally would).
my issue is how to instigate that initial connection.
I've tried this ...
link = Net::HTTP.start('example.com') {|http|
req = Net::HTTP::Get.new('example.com')
http.req.basic_auth 'uname', 'p/word'
http.response = http.request(req)
print response.body
}
@db = Sequel.connectadapter => 'mysql', :host => link, :database
=> 'DB_to_use', :user => 'DB_name', assword => 'p/w')
only to have the index.htm be put to STD OUT.
also tried ....
link = Net::HTTP.new('example.com',uname, p/w)
@db = Sequel.connectadapter => 'mysql', :host => link, :database
=> 'DB_to_use', :user => 'DB_name', assword => 'p/w')
only to have reference to name or service not known
the example.com is the url through which i gain access to the database
at the back.
anyone able to me I'd be grateful.
note before posting this I have edited the above to this....
Net::HTTP.new('example.com') {|http|
req = Net::HTTP::Get('example.com')
http.req.basic_auth 'uname', 'f0ur2010'
http.response = http.request(req)
print response.body
}
@db = Sequel.connectadapter => 'mysql', :host => 'example.com',
:database => 'DB_to_use', :user => 'DB_name', assword => 'p/w')
row = @db[:cust_data]
row.each {|t| puts t}
getting this -
/usr/lib/ruby/1.8/sequel/adapters/mysql.rb:101:in `real_connect':
Mysql::Error: Access denied for user 'db_name'@'example.com' (using
password: YES) (Sequel:atabaseConnectionError)
from /usr/lib/ruby/1.8/sequel/adapters/mysql.rb:101:in `connect'
Dave.
connect to it.
the thing is I've not done it before and am hitting an obstacle to make
this work.
1. it isn't a web server so you don't go http://example.com it is simply
example.com USERNAME PASSWORD (once access is granted you can then
connect to the mysql as you normally would).
my issue is how to instigate that initial connection.
I've tried this ...
link = Net::HTTP.start('example.com') {|http|
req = Net::HTTP::Get.new('example.com')
http.req.basic_auth 'uname', 'p/word'
http.response = http.request(req)
print response.body
}
@db = Sequel.connectadapter => 'mysql', :host => link, :database
=> 'DB_to_use', :user => 'DB_name', assword => 'p/w')
only to have the index.htm be put to STD OUT.
also tried ....
link = Net::HTTP.new('example.com',uname, p/w)
@db = Sequel.connectadapter => 'mysql', :host => link, :database
=> 'DB_to_use', :user => 'DB_name', assword => 'p/w')
only to have reference to name or service not known
the example.com is the url through which i gain access to the database
at the back.
anyone able to me I'd be grateful.
note before posting this I have edited the above to this....
Net::HTTP.new('example.com') {|http|
req = Net::HTTP::Get('example.com')
http.req.basic_auth 'uname', 'f0ur2010'
http.response = http.request(req)
print response.body
}
@db = Sequel.connectadapter => 'mysql', :host => 'example.com',
:database => 'DB_to_use', :user => 'DB_name', assword => 'p/w')
row = @db[:cust_data]
row.each {|t| puts t}
getting this -
/usr/lib/ruby/1.8/sequel/adapters/mysql.rb:101:in `real_connect':
Mysql::Error: Access denied for user 'db_name'@'example.com' (using
password: YES) (Sequel:atabaseConnectionError)
from /usr/lib/ruby/1.8/sequel/adapters/mysql.rb:101:in `connect'
Dave.