Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

localhost vs. 127.0.0.1 in mysql_connect()

Tags:

php

mysql

  1. Does using localhost in mysql_connect() make the connection faster than using 127.0.0.1?
  2. What is the connection type between the PHP script and mySQL (when using the mysql_connect() function) ? Is it TCP/IP?
like image 791
Joel Avatar asked Sep 15 '10 08:09

Joel


1 Answers

  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.
like image 81
halfdan Avatar answered Sep 19 '22 02:09

halfdan