Does civicrm support mysql sockets?
You can set the DSN in the civicrm.settings.php file using this format:

mysqli://user:password@unix(/path/to/socket)/databasename

Use the actual word "unix" in the string to indicate sockets.