Engine23

Mysql - File not found

If you have a mac and have upgraded to the latest operating system 10.10, you may find that mysql is not able to connect.

The fix is pretty easy, its an update to the php.ini

What we need to do is tell mysql to connect through localhost instead of 127.0.0.1

First locate the php.ini you can use the following command in terminal

locate php.ini

Look for something like /private/etc/php.ini

This is an example of what may come back

/Users/engine23/php.ini
/private/etc/php.ini-5.2-previous
/private/etc/php.ini.default
/private/etc/php.ini.default-5.2-previous

You may have may of them and if you dont have one called /private/etc/php.ini it may be named /private/etc/php.ini.default, if so copy that and rename it to just php.ini.

sudo cp /private/etc/php.ini.default /private/etc/php.ini

Now you know what file to edit, using terminal edit that file

sudo vim /private/etc/php.ini

These are the entries you need to update:

  • pdo_mysql.default_socket = /tmp/mysql.sock 
  • mysql.default_socket = /tmp/mysql.sock 
  • mysql.default_host = 127.0.0.1 
  • mysqli.default_socket = /tmp/mysql.sock

Make sure you save that /private/etc/php.ini and restart apache

sudo apachectl -k restart

Now load up your adminer, phpmyadmin or whatever and you should be able to connect using localhost instead of 127.0.0.1

Share: