Answers.Body: <p>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 <a href="https://craftcms.com/docs/installing#step-3-create-your-database" rel="nofollow noreferrer">detailed here</a>) and that it is indeed called ‘mycraft’.</p>
  
  <p>Also check in your MAMP control panel that the MySQL is actually running:</p>
  
  <p><a href="https://i.sstatic.net/jTMBU.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jTMBU.png" alt="enter image description here"></a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-16T12:58:55.500Z
Answers.LastActivityDate: 2017-03-16T12:58:55.500Z
Answers.UserDisplayName: Seth Warburton
Answers.Body: <p>This happens when you go from old versions of craft, in the latest versions you have to have the <code>config/db.php</code> file like this:</p>
  <pre><code>&lt;?php
  use craft\helpers\App;
  
  return [
      'dsn' =&gt; App::env('DB_DSN') ?: null,
      'driver' =&gt; App::env('DB_DRIVER'),
      'server' =&gt; App::env('DB_SERVER'),
      'port' =&gt; App::env('DB_PORT'),
      'database' =&gt; App::env('DB_DATABASE'),
      'user' =&gt; App::env('DB_USER'),
      'password' =&gt; App::env('DB_PASSWORD'),
      'schema' =&gt; App::env('DB_SCHEMA'),
      'tablePrefix' =&gt; App::env('DB_TABLE_PREFIX'),
  ];
  </code></pre>
  <p>Also make sure you have the correct database credentials in the <code>.env</code> file and delete a line called DSN if you have it.</p>
  <p>I used composer.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-18T17:32:59.930Z
Answers.LastActivityDate: 2021-02-23T16:04:50.213Z
Answers.LastEditDate: 2021-02-23T16:04:50.213Z
Answers.UserDisplayName: Alexis Dalai Waldo Jiménez
Body: <p>I'm using MAMP to setup a local environment for CraftCMS on Windows 10. </p>
  
  <p>I have followed all necessary procedures and have my local host and my database setup but I'm still receiving the error mentioned above.</p>
  
  <p>My db.php is shown as this:</p>
  
  <pre><code> return array(
  
          // The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
         'server' =&gt; 'localhost',
  
          // The name of the database to select.
          'database' =&gt; 'mycraft',
  
         // The database username to connect with.
         'user' =&gt; 'root',
  
         // The database password to connect with.
        'password' =&gt; 'root',
  
         // The prefix to use when naming tables. This can be no more than 5 characters.
        'tablePrefix' =&gt; 'craft',
  
   );
  </code></pre>
  
  <p>Even if i make a custom user or password I still get the error above when I try to connect to <a href="http://localhost:8888/admin" rel="nofollow noreferrer">http://localhost:8888/admin</a></p>
  
  <p>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...</p>
  
  <p>Anyone know what's going on?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-03-14T07:38:53.187Z
Comments.Text: 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`
Comments.UserDisplayName: Justin Dekkers
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-03-14T07:42:17.040Z
Comments.Text: 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
Comments.UserDisplayName: Justin Dekkers
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-03-14T07:45:15.733Z
Comments.Text: 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...
Comments.UserDisplayName: HK94
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-03-14T08:06:02.860Z
Comments.Text: https://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.
Comments.UserDisplayName: Justin Dekkers
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-03-14T12:40:16.120Z
Comments.Text: Any luck connecting with this: https://gist.github.com/M165437/421cd2d23e53a111541a483971f7368b
Comments.UserDisplayName: Clive Portman
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-03-14T22:46:50.877Z
Comments.Text: nope, that hasn't worked either. Maybe I should try Wamp or Xamp or something...
Comments.UserDisplayName: HK94
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-03-15T00:24:26.580Z
Comments.Text: ok, so I've tried Wamp which just completely didn't work at all and then I tried Xampp and finally got it working live. Xampp being the one that worked for me with my OS and config I guess I don't really know. I used the exact same settings I used on MAMP for Xampp and it just worked... meh... Anyway thanks for taking the time to help out guys :)
Comments.UserDisplayName: HK94
Tags: <error-message><environments>
Title: MAMP: Craft can’t connect to the database with the credentials in craft/config/db.php
ThreadText: # MAMP: Craft can’t connect to the database with the credentials in craft/config/db.php
  
  (Asked by: username_0 on 2017-03-14)
  
  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 '127.0.0.1'.
         '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?
  
  **Tags:** error-message, environments
  
  > **Comments:**
  > **username_1**: 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`  
  > **username_1**: 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  
  > **username_0**: 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...  
  > **username_1**: https://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.  
  > **username_2**: Any luck connecting with this: https://gist.github.com/M165437/421cd2d23e53a111541a483971f7368b  
  > **username_0**: nope, that hasn't worked either. Maybe I should try Wamp or Xamp or something...  
  > **username_0**: ok, so I've tried Wamp which just completely didn't work at all and then I tried Xampp and finally got it working live. Xampp being the one that worked for me with my OS and config I guess I don't really know. I used the exact same settings I used on MAMP for Xampp and it just worked... meh... Anyway thanks for taking the time to help out guys :)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2017-03-16. Score: 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](https://craftcms.com/docs/installing#step-3-create-your-database)) and that it is indeed called ‘mycraft’.
  
  Also check in your MAMP control panel that the MySQL is actually running:
  
  [![enter image description here](https://i.sstatic.net/jTMBU.png)](https://i.sstatic.net/jTMBU.png)
  
  
  ---
  
  ### Answer by username_4 on 2021-02-18. Score: 1
  
  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:
  
  ```
  <?php
  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.
  
  
  ---
  
  