MySQL socket DSN connection syntax

Usually I just bung in 127 or localhost in order to connect up to my DB. However, if you aren’t allowing remote connections, then running on a unix socket is much faster and skips all the networking overhead involved with TCP/IP.

So! To use a socket, you use a DSN for the connection. I’ve done this a few times, but I keep forgetting the syntax, sop here it is, solely for my own memory’s sake:

mysql:unix_socket=/tmp/mysql.sock;dbname=my_db_name_here
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s