2

I am running a local MAMP machine on my Mac. Laravel running in production environment. Laravel is able to access the MySQL DB on php pages I display through the browser, yet when I am running php artisan migrate in Terminal, I receive

[PDOException]                                                                          
  SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

app/config/database:

'mysql' => array(
    'driver'    => 'mysql',
    'host'      => 'localhost',
    'database'  => 'laravel1',
    'username'  => 'root',
    'password'  => 'root',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
    'port'      => '8889'
),

ATTEMPTED SOLUTION:

Adding 'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock' (path designated in /Applications/MAMP/bin/startMysql.sh) to app/config/database.

Results in error:

[PDOException]                                    
  SQLSTATE[HY000] [2002] No such file or directory 

Help appreciated.

Matteo
  • 37,680
  • 11
  • 100
  • 115
i_love_nachos
  • 411
  • 1
  • 4
  • 14
  • Are you sure that your root password is 'root'? – Pablo Martinez Sep 15 '14 at 14:21
  • I would have hoped that the fact that everything works in my browser assures the user and pw are correct as my Laravel site is able to connect to the database using `root` / `root`. Is this a false assumption? – i_love_nachos Sep 15 '14 at 14:26
  • How did you define your environments? – marcanuy Sep 15 '14 at 16:26
  • I have done nothing to modify environments. All I have touched in config are the above provided database details for production environment. What are environments defined for and where is it done - what should I do? – i_love_nachos Sep 15 '14 at 16:43
  • I think artisan is using you CLI version of PHP which is different from what MAMP uses. Try running `which php` in the console and compare with your `phpinfo()` – cecilozaur Sep 16 '14 at 07:37
  • Thanks for the response. phpinfo() shows `Loaded Configuration File` as `/Applications/MAMP/bin/php/php5.5.14/conf/php.ini`, whereas `which php` in Terminal returns `/usr/local/php5-5.5.16-20140822-215341/bin/php`. What now? – i_love_nachos Sep 16 '14 at 07:59
  • Cheers! Problem is fixed. – i_love_nachos Sep 16 '14 at 09:58

1 Answers1

2

Ran which php in terminal, then ran phpinfo() on site. Found out different versions of php were used by MAMP and Terminal. Fixed using THIS METHOD. Everything works thanks to @cecilozaur.

Community
  • 1
  • 1
i_love_nachos
  • 411
  • 1
  • 4
  • 14