[R] connecting RMySQL to and external server

Gabor Grothendieck ggrothendieck at gmail.com
Sat Dec 15 17:54:20 CET 2007


Use ssh forwarding to forward local port 3307 to remote port 3306
specifying the remote account and password.  Then if you use local port
3306 you can access your local version of MySQL and if you
use port 3307 you can access the remote version.   There is some
info on the MySQL site.  First test it out by running the mysql command
line program accessing the remote data base via port 3307 and once
that works you know its ok and you can try RMySQL or RODBC packages.

On Dec 15, 2007 11:33 AM, Adrian Dusa <dusa.adrian at gmail.com> wrote:
>
> Indeed, I noticed the "host" argument but the server demands an username and a
> password for the machine first, and only after that for the MySQL server.
> Those were the arguments I was looking for.
> I will study the RODBC package then, if it solves the problem.
>
> Thank you very much,
> Adrian
>
>
>
> On Saturday 15 December 2007, Prof Brian Ripley wrote:
> > It is trivial with RODBC (I know that is not what you asked, but it is the
> > solution we found first).
> >
> >
> > For RMySQL, note first that the MySQL configuration file is consulted, so
> > the default host is specified in the client section, which is like
> >
> > [client]
> >
> > port=3306
> >
> > [mysql]
> >
> > default-character-set=latin1
> >
> > Add host=foo under [client] to change the default host.
> >
> > And ?dbConnect mentions a 'host' argument under '...'.  That seems to work
> > for me (provided of course the server allows connections from other
> > machines): on my home network from Windows laptop to Linux server
> >
> > > library(RMySQL)
> >
> > Loading required package: DBI
> >
> > > drv <- dbDriver("MySQL")
> > > con <- dbConnect(drv, user="ripley", host="auk", dbname="ripley")
> >
> > This mixture of using the *local* configuration file overridden by
> > arguments is a bit dangerous: RMySQL seems not really designed for
> > client-server operation and there are some things that definitely do not
> > work.  (As I recall, that included dbWrite as that imports a file which is
> > on the local machine.)
> >
> > On Fri, 14 Dec 2007, Adrian Dusa wrote:
> > > Dear list,
> > >
> > > I learned how to connect R to a local MySQL server, using:
> > > drv <- dbDriver("MySQL")
> > > con <- dbConnect(drv, user="root", password="mypass", dbname="mydb")
> > >
> > > Is it possible to connect R in this way to an external server (on a
> > > different machine, with a different IP)?
> > >
> > > I read the documentation on ?dbConnect (and everything I could find on
> > > the internet), but I failed to find some other relevant arguments. For
> > > example, one needs to first connect to the external machine and only
> > > after that to the MySQL server on that machine. Is this possible from
> > > within R?
> > >
> > > Thank you in advance,
> > > Adrian
>
>
>
> --
> Adrian Dusa
> Romanian Social Data Archive
> 1, Schitu Magureanu Bd
> 050025 Bucharest sector 5
> Romania
> Tel./Fax: +40 21 3126618 \
>          +40 21 3120210 / int.101
>
> ______________________________________________
>
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list