mysql - mysql_connect: IP Address or Localhost? -
i saw following statement on stackoverflow , wondering meaning:
if connect via 'localhost', connection automatically established via mysql socket, inexpensive anyways.
the give-and-take thread pretty old, didn't want comment on it. understand is, using 'localhost' when connecting mysql database has advantages - such "automatically established connections via mysql socket". mean exactly?
currently i'm using mysql_connect("73.21.24.201", [...]);
(changed random ip address) create difference? can alter "localhost" without having worry it? (the mysql server on same server/ip address website/application)
when connect 'localhost' you'll connect using unix socket, communications channel local processes use. big advantage of can disable networking completely in mysql, , negate processing overhead , security risks go along that.
when mysql starts, creates socket file (typically @ place /var/lib/mysql/mysql.sock
) client programme needs able find. on typical php (you didn't say, i'm assuming) setup, should know find socket. if not, check /etc/my.cnf
, /etc/php.ini
create sure values match.
and finally, if php, stop using mysql_*()
functions in php right now! they have been deprecated years , inefficient , insecure.
mysql sockets
No comments:
Post a Comment