I believe that I\'ve successfully deployed my (very basic) site to fortrabbit, but as soon as I connect to SSH to run some commands (such as php artisan migrate
For anyone trying to create a fresh db connection not on laravel but bumped here seeking for answers to run PDO from the Terminal. This would be of help to you. And you can refactor it to work best for you.
SOCKS == '')
{
// run shell command to get
$socks = shell_exec('netstat -ln | grep mysql');
$socks = trim(substr($socks, strpos($socks, '/')));
$this->SOCKS = strlen($socks) > 0 ? ';unix_socket='.$socks : '';
}
else
{
$this->SOCKS = ';unix_socket='.$this->SOCKS;
}
$dsn = $this->DRIVER.':host='.$this->DBHOST.';dbname='.$this->DB;
// add socks
$dsn .= $this->SOCKS;
// add port
$dsn .= (strlen($this->PORT) > 0) ? ';port='.$this->PORT : '';
// extablish connection
$con = new PDO($dsn, $user, $pass);
// return PDO instance.
return $con;
}
// - ends here
// now you can call $this->con() within class to use connection
// would run fine on any terminal
}
hope it helps!