What is the socket declaration for, in Ruby on Rails database.yml?

MySQL has two methods of communicating with it on unix-ish systems, tcp/ip and domain sockets. By specifying the socket Rails, or rather the database driver, will use the socket instead of a network connection. It can be quicker to use the socket but YMMV.

http://dev.mysql.com/doc/refman/5.5/en/connecting.html


When two programs want to talk to each other over the network, one program might open up a TCP connection (a "socket") with the other one. The first program needs to know the IP address of the second computer and the port on which the program is listening.

On Linux, when two programs on the same computer want to talk to each other, they can still open up a TCP connection. But they can also open up a connection via a "socket file". Linux makes the socket file API rather similar to the TCP API, so it's not a big deal to update a program that already communicates over the network via TCP to support communicating via socket files too. Socket files are faster than TCP, but only work when both programs are on the same computer.