Configure mysql.sock to connect to local mySQL server through socket

Can’t connect to local MySQL server through socket /tmp/mysql.sock

The cause is: The mySQL by default attempts to connect through a local file called a socket instead of connecting to the address ( for localhost. The default location of this socket file, at least on OSX, is /tmp/mysql.sock.

Run this code in the terminal to create symlink to finding the correct socket.

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock

After this you will need to reboot your mySQL to take effect.

Hopefully this helps you alot from having a rough morning.

Posted in PHP

5 thoughts on “Configure mysql.sock to connect to local mySQL server through socket

  1. Trying to host inventory management system 2years back which you made it. on IIS server.

    My aim is to publicly host this web application. Please guid me with the steps.

    I have uploaded this inventory system to my online web server(IIS), so when i try to connect by entering the hostname, i am able to view the credentials page(Home Page) but while entering the credentials,

    i can never get to the dashboard page .The web address changes to “” and the page it displays “The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.”

    Since I’ve changed the $config[‘base_url’] = ‘http://mydomainname:portnumber/’; in config.php file

    Also i did the following changes in the htaccess file in the root directory and changed the

    RewriteRule ^(.*)$ index.php/$1 [L,QSA]  


    RewriteRule ^(.*)$ index.php?/$1 [L]

    I feel i am going wrong somewhere in the config.php file

    If you could please help me out i would greatly appreciate it. I really like the design and it is exactly what i have been looking for to control my stock.

    thanks You!!

Leave a Reply

Your email address will not be published. Required fields are marked *