Nova Framework

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.