localhost vs. 127.0.0.1 in mysql_connect()

  1. Differs between Windows and Linux. If you use a unix domain socket it’ll be slightly faster than using TCP/IP (because of the less overhead you have).
  2. Windows is using TCP/IP as a default, whereas Linux tries to use a Unix Domain Socket if you choose localhost and TCP/IP if you take 127.0.0.1.

Leave a Comment