Nova Framework

David Carr

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.

Domains are often purchased from multiple providers, keeping track of where a domain is and its DNS settings can be tricky. Domain Mapper solves this by listing all your domains in one place. View your DNS settings and receive reminders to renew your domains. Try it today.

Support my work by donating with PayPal.

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2009 - 2021 DC Blog. All code MIT license. All rights reserved.