Carl Youngblood
2005-Oct-19 22:41 UTC
OT: Accessing mysql database from socket versus hostname
I noticed when I updgraded to 0.14.1 that my database.yml has references to the mysql socket path instead of the hostname. Is there an advantage to accessing the server through the socket instead of the host? Thanks, Carl
Daniel Hobe
2005-Oct-20 03:49 UTC
Re: OT: Accessing mysql database from socket versus hostname
Unix sockets should be lower overhead than a TCP connection, so there is a possible performance gain (you don''t need to do any of the checksuming, retransmit etc) . If you can keep mysql off the network (your rails app and db are on the same box), someone couldn''t try to break into your database over the network, so I guess there is some security benefit. I think both of these are fairly negligible gains for any real world Rails app, so there is probably no real difference. On 10/19/05, Carl Youngblood <carl-MJzSGySFh6ZUfOvSQQQpYw@public.gmane.org> wrote:> I noticed when I updgraded to 0.14.1 that my database.yml has > references to the mysql socket path instead of the hostname. Is there > an advantage to accessing the server through the socket instead of the > host? > > Thanks, > Carl > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Daniel Hobe <hobe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> After the darkness of her speech; I go bewildered in a mist of prophecies.
Courtenay
2005-Oct-20 03:57 UTC
Re: OT: Accessing mysql database from socket versus hostname
On 10/19/05, Daniel Hobe <hobe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Unix sockets should be lower overhead than a TCP connection, so there > is a possible performance gain (you don''t need to do any of the > checksuming, retransmit etc) . > > If you can keep mysql off the network (your rails app and db are on > the same box), someone couldn''t try to break into your database over > the network, so I guess there is some security benefit. > > I think both of these are fairly negligible gains for any real world > Rails app, so there is probably no real difference.However mysql will always look for a socket if you supply your host as "localhost", and will ignore any port settings; whereas setting 127.0.0.1 will use any ports you specify (I use a different port for a tunneled DB connection).