Search code examples
mysqlapachesecuritydatabase-performance

MySQL port or socket?


My Apache and MySQL server are on the same machine, and MySQL is configured to listen to localhost:3306

Are there any security or performance benefits with this configuration when compared to using a socket file instead of localhost and port?

Thanks!


Solution

  • Ideally, for security, you'd want to move the MySQL to a separate machine outside of the demilitarized zone. That is, it should be contactable by the web server, being on the same network, but blocked from incoming internet traffic. That way, getting the web server doesn't also get you the database.

    The world isn't perfect, and we sometime have to host things together. As long as the port is blocked by a firewall to all traffic except the loopback, there should be little to no difference security wise between a port and sock file.