Nova Framework

Using MAMP and dealing with the error: mysql No such file or directory

I’ve got a fresh install of Nova Framework installed and decided to use MAMP as my server and database management, one problem that can happen is when running Nova’s CLI forge commands can fail giving this error:

{"error":{"type":"PDOException","message":"SQLSTATE[HY000] [2002] No such file or directory","file":"novaframework\/vendor\/nova-framework\/system\/src\/Database\/Connector.php","line":62}}

This happens when terminal cannot connect to mysql in MAMP’s case the solution is to specify the path to the mysql.sock in app/Config/Database.php add this to the mysql array:

'unix_socket'   => '/Applications/MAMP/tmp/mysql/mysql.sock',

So it looks like:

'mysql' => array(
      'driver'    => 'mysql',
      'hostname'  => 'localhost',
      'database'  => 'nova',
      'username'  => 'root',
      'password'  => 'root',
      'prefix'    => PREFIX,
      'charset'   => 'utf8',
      'collation' => 'utf8_general_ci',
      'unix_socket'   => '/Applications/MAMP/tmp/mysql/mysql.sock',

That’s it! now terminal can connect to mysql and use the forge commands.

David Carr

David Carr

For the past 12 years, I’ve been developing applications for the web using mostly PHP. I do this for a living and love what I do as every day there is something new and exciting to learn.

In my spare time, the web development community is a big part of my life. Whether managing online programming groups and blogs or attending a conference, I find keeping involved helps me stay up to date. This is also my chance to give back to the community that helped me get started, a place I am proud to be apart of.

Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie, staying in playing games on the sofa or planning a trip to someplace I’ve never been before.