Question: My mysql server is installed on the localhost machine where my php scripts are stored. So is what they say right that it's safer to connect to mysql from php that is placed in the same server?

If so, how to configure mysql to be connected via sockets instead of localhost:3306? Thanks!

Answer: 
The MySQL client utilities and libraries will automatically connect via the unix socket, rather than via a TCP socket, if you connect to "localhost". You can force it to connection to localhost via TCP by using "127.0.0.1". 

The basic reasoning is to protect MySQL by not allowing access from the network. This can be achieved using

```
 bind-address            = 127.0.0.1

```

in your /etc/mysql/my.cnf file. This is just as secure as "skip-networking" but has the advantage that you don't have to worry about whether you're connecting via TCP or unix socket.
[skip-networking](http://dev.mysql.com/doc/refman/5.0/en/server-options.html#option_mysqld_skip-networking) should do the trick.