Answers.Body: <p>I am also using MAMP on a Mac, and had similar issues first setting up. There are a few things to check.</p>
  <p>Under your host settings, use the traditional ports instead of MAMP's custom ports, and set your servers to run as your local Mac user.</p>
  <p><a href="https://i.sstatic.net/k5h1a.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/k5h1a.png" alt="enter image description here" /></a></p>
  <p>Then on the MySQL settings window, make sure to allow incoming connections, and check the box to include it in &quot;group start&quot;. You can also confirm it's on the right port, here, in the upper right.</p>
  <p>(I also suggest using MAMP to change the MySQL root user password - I set it to <code>root</code> which is the MAMP default.)</p>
  <p><a href="https://i.sstatic.net/nJNU9.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/nJNU9.png" alt="enter image description here" /></a></p>
  <p>Lastly, make sure you and MAMP are both using the same MySQL!  If you have it installed via homebrew as well, then you might not be running the same as MAMP does. On the command line, you can use the one in MAMP via:</p>
  <p><code>/Applications/MAMP/Library/bin/mysql -h localhost ...</code></p>
  <p>Assuming you're using the defaults, first, Run <code>./craft setup</code> and use the following:</p>
  <p>Database driver: <code>mysql</code> <br>
  Database server: <code>localhost</code> <br>
  Database port: <code>3306</code> <br>
  Database username: <code>root</code> <br>
  Database password: <code>root</code> <br></p>
  <p>There are also <a href="https://craftcms.com/knowledge-base/database-backups-in-craft-3-with-mamp" rel="nofollow noreferrer">custom backup and restore commands</a> that work better for MAMP and Craft CMS which you might find helpful.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-18T23:27:31.763Z
Answers.Text: Thanks for a really great and detailed answer! That was very helpful and you were right. I had mysql set up via Homebrew. Once I deleted that things got a whole lot easier.
Answers.UserDisplayName: cannon303
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-18T23:29:09.320Z
Answers.Text: Also I didn't have Allow Network access to MySQL ticked in MAMP which you had in your screenshot which was the final hurdle.
Answers.UserDisplayName: cannon303
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-20T16:17:55.673Z
Answers.Text: I'm really glad I was able to help!  <3
Answers.UserDisplayName: Tammy Shipps
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-15T12:26:26.543Z
Answers.LastActivityDate: 2021-04-15T12:26:26.543Z
Answers.UserDisplayName: Tammy Shipps
Body: <p>Hi I am trying to set up craft CMS with composer. I am using MAMP on a mac and I just cannot get it to connect. I get this error even though I know the password is correct.</p>
  <pre><code>failed: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
  </code></pre>
  <p>I have tried setting up a new user with new password and ensure full access privileges are set up on that database but I get the same error. I have tried setting up a separate host but when I try and run the Craft CMS set up with that I get this error:</p>
  <pre><code>Testing database credentials ... failed: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known
  </code></pre>
  <p>Any help with this would be much appreciated as I've wrestled with it all day now. Thanks.</p>
  
Tags: <craft3><composer><mamp>
Title: Error with Craft CMS set up and composer: failed: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
ThreadText: # Error with Craft CMS set up and composer: failed: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
  
  (Asked by: username_0 on 2021-04-13)
  
  Hi I am trying to set up craft CMS with composer. I am using MAMP on a mac and I just cannot get it to connect. I get this error even though I know the password is correct.
  
  ```
  failed: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
  
  ```
  
  I have tried setting up a new user with new password and ensure full access privileges are set up on that database but I get the same error. I have tried setting up a separate host but when I try and run the Craft CMS set up with that I get this error:
  
  ```
  Testing database credentials ... failed: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known
  
  ```
  
  Any help with this would be much appreciated as I've wrestled with it all day now. Thanks.
  
  **Tags:** craft3, composer, mamp
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-04-15. Score: 1 | Accepted answer
  
  I am also using MAMP on a Mac, and had similar issues first setting up. There are a few things to check.
  
  Under your host settings, use the traditional ports instead of MAMP's custom ports, and set your servers to run as your local Mac user.
  
  [![enter image description here](https://i.sstatic.net/k5h1a.png)](https://i.sstatic.net/k5h1a.png)
  
  Then on the MySQL settings window, make sure to allow incoming connections, and check the box to include it in "group start". You can also confirm it's on the right port, here, in the upper right.
  
  (I also suggest using MAMP to change the MySQL root user password - I set it to `root` which is the MAMP default.)
  
  [![enter image description here](https://i.sstatic.net/nJNU9.png)](https://i.sstatic.net/nJNU9.png)
  
  Lastly, make sure you and MAMP are both using the same MySQL! If you have it installed via homebrew as well, then you might not be running the same as MAMP does. On the command line, you can use the one in MAMP via:
  
  `/Applications/MAMP/Library/bin/mysql -h localhost ...`
  
  Assuming you're using the defaults, first, Run `./craft setup` and use the following:
  
  Database driver: `mysql`   
  Database server: `localhost`   
  Database port: `3306`   
  Database username: `root`   
  Database password: `root`
  
  There are also [custom backup and restore commands](https://craftcms.com/knowledge-base/database-backups-in-craft-3-with-mamp) that work better for MAMP and Craft CMS which you might find helpful.
  
  > **Comments:**
  > **username_0**: Thanks for a really great and detailed answer! That was very helpful and you were right. I had mysql set up via Homebrew. Once I deleted that things got a whole lot easier.  
  > **username_0**: Also I didn't have Allow Network access to MySQL ticked in MAMP which you had in your screenshot which was the final hurdle.  
  > **username_1**: I'm really glad I was able to help!  <3  
  
  ---
  
  