Error with Craft CMS set up and composer: failed: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
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.

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.
(I also suggest using MAMP to change the MySQL root user password - I set it to root which is the MAMP default.)

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 that work better for MAMP and Craft CMS which you might find helpful.