user3732216 user3732216 - 6 months ago 98
MySQL Question

MAMP with Laravel Unix Socket

I'm working with MAMP on my local development server on my laravel application and I'm trying to figure out how I can safely setup my server so I don't have to use the following into the database connections mysql array because that should only be used when I'm on my development server. It works when I add the line into the mysql array however that isn't used if I was on a production server. Any ideas?

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



return [
'DB_HOST' => '',
'DB_USERNAME' => 'root',
'DB_PASSWORD' => '1234',
'DB_NAME' => 'mytable'


'connections' => array(

'mysql' => array(
'driver' => 'mysql',
'host' => getenv('DB_HOST'),
'database' => getenv('DB_NAME'),
'username' => getenv('DB_USERNAME'),
'password' => getenv('DB_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',


Check the environment detection part in the bootstrap/start.php. You should add your machine's name to the array that has local key. (If you don't know your machine's name, run hostname in terminal. If it's something stupid, Google how to change it. It's pretty simple.) Then copy and paste your database configurations to app/config/local/database.php. Create the file if it doesn't exists.