6

I've installed Craft 3 through composer and I'm attempting to work through the setup process within terminal:

MacBook-Pro:~ jamie$ ~/Documents/repos/__craft-3-beta/craft setup
Which database driver are you using? [mysql,pgsql,?]: mysql
Database server name or IP address: [localhost] 
Database port: [3306] 
Database username: [root] 
Database password: 
Database name: craft-three
Database table prefix: 
Testing database credentials... failed: SQLSTATE[HY000] [2002] No such file or directory
Which database driver are you using? [mysql,pgsql,?]: mysql
Database server name or IP address: [localhost] 127.0.0.1
Database port: [3306] 
Database username: [root] 
Database password: 
Database name: [craft-three] 
Database table prefix: 
Testing database credentials... failed: SQLSTATE[HY000] [2002] Connection refused

Notice that I get 2 different errors when using the IP add and localhost for DB_SERVER

I also cant get it working when manually filling in the .env file.

I'm using MAMP Pro on a Mac.

Any help on this will be greatly appreciated.

  • did you use root for your db password? I had issues here as had changed it in the past, so used a new user/pw – user2569 Dec 8 '17 at 13:39
  • I've tried 'root' and leaving it blank. Both result in the same errors. I dont really want to change my root password, as i'll have to change all instances of the password within phpMyAdmin, and other scripts which are used with MAMP – Spacecentre Dec 8 '17 at 15:32
  • Don't have MAMP install locally, but doesn't it use a different database port by default? – Brad Bell Dec 8 '17 at 17:45
5

I was just confronted with this too. You most likely need to specify the unixSocket attribute for the MAMP Pro database. Take a look at my problem and solution at Craft CLI RC1 Connectivity Issues with MAMP Pro. Though if you're not able to get it working at all even manually I would definitely suggest resetting your root password in MAMP Pro as well.

| improve this answer | |
1

Had very similar issues but no MAMP or WAMP; just vanilla Apache and MySQL 5.7.23 (Had the same error with 8.0.12 too - did not test the solution).

It worked for me to type in 127.0.0.1 instead of blank or localhost in the terminal window when going through the Craft3 setup steps.

Which database driver are you using? [mysql,pgsql,?]: mysql
Database server name or IP address: [localhost] 127.0.0.1
Database port: [3306] 
Database username: [root] 
Database password: 
Database name: craft_test_h828
Database table prefix: 
Testing database credentials... success!
Saving database credentials to your .env file... done
| improve this answer | |
1

This note is a "thank you" to the commentators above. After a few hours of "slugging" (starting with the effort to download composer), here is what worked for me:

Which database driver ... : mysql
Database server name or IP ... : 127.0.0.1
Database port: [3306] 8889 (note: via MAMP)
Database username: [root] root
Database password:
Database name: EnergyAudit
Database table prefix (type "none" for none): Probs
Testing database credentials ... success!
Saving database credentials to your .env file ... done
| improve this answer | |
1

Nothing worked mentioned here.

But after these steps

  1. Enable "Allow network access to MySQL" -> "only from this Mac"
  2. Save
  3. Restart

It worked!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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