Search code examples
phpmysqllaravelweb-deploymentpagoda-box

Laravel 4 & Pagoda: [PDOException] SQLSTATE[HY000] [2002] No such file or directory


So, my app is on this link

I am able to create a tunnel using Pagoda client and I can view databases via the mySQL CLI. That command being mysql -u<DBusername> -p<DBpassword> -htunnel.pagodabox.com -P<the port tunnel shows me to connect on e.g. 3306>

The app works locally. Okay, further i've searched and searched, did the app/database.php configuration, checked the socket, it's okay too, at /var/run/mysqld/mysqld.sock .

The error is this: In my Boxfile, I have this before-deploy hook before_deploy: - "php artisan migrate:install --env=production"

This causes the [PDOException] SQLSTATE[HY000] [2002] No such file or directory and hence it isn't deployed.

Any help\reference would be really welcome. Any more info can be given too. Cheers!


Solution

  • Modified the mysql configuration in my app/config/database.php to this:

    'host' => isset($_SERVER['DB1_HOST']) ? $_SERVER['DB1_HOST'] : '127.0.0.1', 'database' => isset($_SERVER['DB1_NAME']) ? $_SERVER['DB1_NAME'] : '<db_name>', 'username' => isset($_SERVER['DB1_USER']) ? $_SERVER['DB1_USER'] : '<mysql_username>', 'password' => isset($_SERVER['DB1_PASS']) ? $_SERVER['DB1_PASS'] : '<mysql_password>',

    That solved my problem!