MAMP : Error: Could not connect to MySQL server!

MAMP : Error: Could not connect to MySQL server!


I recently changed my root password for MySQL and forgot that I had done so.. when I restarted MAMP I got :


Error: Could not connect to MySQL server!

MAMP : Error: Could not connect to MySQL server!

Simple fix, open :


/Applications/MAMP/bin/mamp/index.php

and update the root users password :

$link = @mysql_connect(':/Applications/MAMP/tmp/mysql/mysql.sock', 'root', 'newpassword');

if you get this screen :

#1045 - Access denied for user 'root'@'localhost' (using password: YES)

#1045 - Access denied for user 'root'@'localhost' (using password: YES)

Simple Fix : Open

/Applications/MAMP/bin/phpMyAdmin/config.inc.php

Update line below with new password (note: this is for a basic install of MAMP on Mac).


$cfg['Servers'][$i]['password'] = root

14 thoughts on “MAMP : Error: Could not connect to MySQL server!

  1. Michael Stelly

    hmm. didn’t work for me. i’ll keep searching.
    my index.php = $link = @mysql_connect(‘:/Applications/MAMP/tmp/mysql/mysql.sock’, ‘root’, ‘root’);
    my config.ini.php = $cfg[‘Servers’][$i][‘password’] = ‘root’;

    Thanks for the post.

    Reply
    1. Kim Pomares

      I keep forgetting to clear browser data!!! Just wasted 30 minutes on this. After fixing everything, I could not figure out why I was still getting this error from phpMyAdmin.

      Reply
  2. Craig

    @tebx
    I can’t thank you enough!!! I know I’m savvy enough to edit a few files, but it still wouldn’t connect. Several hours later, I realize that all I have to do is empty my browser cache!!! After hours of serious web browsing, you’re comment saves the day (as in the day that I lost trying to figure this out!). THANKS!!!

    Reply
  3. stensiggaard

    and remember to allow root login in this line

    $cfg[‘Servers’][$i][‘AllowRoot’] = TRUE; // whether to allow root login

    Reply

Leave a comment