Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect a Laravel app to MySQL using MAMP?

SOLVED: I followed what this website said http://forums.laravel.io/viewtopic.php?id=980 I just added 'unix_socket' to the mysql array and it worked!

I am following the Laravel quick start guide at http://laravel.com/docs/quick

I have everything set up and am using MAMP. When I try and view the /public/users page, I am hit with:

PDOException

SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)" error.

My database.php file looks like so:

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

My MAMP displays:

host        localhost
port        8889
user        root
password    root

My question is, is the MySQL on MAMP's separate from the MySQL tables I have created locally? I am assuming yes because I am not able to see the tables on PHPMyAdmin. If so, is there a way to connect my Laravel app to MAMP's MySQL?

like image 766
Josh L Avatar asked Aug 14 '13 20:08

Josh L


1 Answers

MAMPs MySQL is running on port 8889, so add 'port' => '8889' to your config array

like image 159
Erin Drummond Avatar answered Oct 14 '22 01:10

Erin Drummond