I'm using MAMP to setup a local environment for CraftCMS on Windows 10.

I have followed all necessary procedures and have my local host and my database setup but I'm still receiving the error mentioned above.

My db.php is shown as this:

 return array(

        // The database server name or IP address. Usually this is 'localhost' or ''.
       'server' => 'localhost',

        // The name of the database to select.
        'database' => 'mycraft',

       // The database username to connect with.
       'user' => 'root',

       // The database password to connect with.
      'password' => 'root',

       // The prefix to use when naming tables. This can be no more than 5 characters.
      'tablePrefix' => 'craft',


Even if i make a custom user or password I still get the error above when I try to connect to http://localhost:8888/admin

I've checked many times and all my credentials as well as my local host port is correct. Craft can clearly connect to host which is why I'm getting the error from craft but for some reason, despite the details in db.php being correct it cant connect to the database...

Anyone know what's going on?

  • Shouldn't you be using Xamp or Wamp on Windows instead of MAMP as it is for OSX. If you are using wamp or xamp your "root" account doesn't have a password set at the beginning plus I am 90% sure you dont need to type localhost then and just go to your folder like localhost/website Commented Mar 14, 2017 at 7:38
  • other thing might be that you have to put index.php before /admin so like: http://localhost:8888/index.php/admin Maybe your .htaccess isnt set the right way for your server Commented Mar 14, 2017 at 7:42
  • hmm when I visited MAMP it had a version for Windows so I thought it could still be used. Maybe I'm missing 1 or two steps for windows. The thing is craft is working using MAMP, the issue is just with the database. I've tried using 'index.php' before /admin but to no avail. I haven't setup anything in my .htaccess maybe that's the issue. I'm not sure what to do with it though...
    – HK94
    Commented Mar 14, 2017 at 7:45
  • craftcms.com/support/remove-index.php You should check that out for your .htaccess But you can try leaving your password out but I cant imagine it would be 100% good using MAMP on windows. Maybe try WAMP or XAMP. I remember back in school I had a couple sites running on WAMP using craft. Can't say that about MAMP. Never tried it. Commented Mar 14, 2017 at 8:06
  • Any luck connecting with this: gist.github.com/M165437/421cd2d23e53a111541a483971f7368b Commented Mar 14, 2017 at 12:40

2 Answers 2


The default MAMP DB credentials are indeed root:root, as you have already, so you should check that you did indeed create a database (set up as detailed here) and that it is indeed called ‘mycraft’.

Also check in your MAMP control panel that the MySQL is actually running:

enter image description here


This happens when you go from old versions of craft, in the latest versions you have to have the config/db.php file like this:

use craft\helpers\App;

return [
    'dsn' => App::env('DB_DSN') ?: null,
    'driver' => App::env('DB_DRIVER'),
    'server' => App::env('DB_SERVER'),
    'port' => App::env('DB_PORT'),
    'database' => App::env('DB_DATABASE'),
    'user' => App::env('DB_USER'),
    'password' => App::env('DB_PASSWORD'),
    'schema' => App::env('DB_SCHEMA'),
    'tablePrefix' => App::env('DB_TABLE_PREFIX'),

Also make sure you have the correct database credentials in the .env file and delete a line called DSN if you have it.

I used composer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.