Having installed Craft 3 using Composer, I'm attempting to run the Craft setup. Everytime I try, I get the following error:

Testing database credentials... failed: SQLSTATE[HY000] [1044] Access denied for user 'xxx'@'%' to database 'xxx'

where xxx is the correct username and db name. Obviously, it can't connect to the database for some reason. I have also attempted the entire install manually without Composer and get the same issue with not connecting to the db. I have also tried manually editing the .env file with the correct details after installing with Composer. No joy.

Looking at the error, I would expect the user to read: user 'xxx'@'localhost' given that I specified localhost as the server. I'm not sure why it specifies '@' instead but I suspect that is a clue.

I believe that port 3306 is used as the default TCP/IP port and that simply not specifying a port will not lead it to use Unix Socket instead. I raise this as I believe it may also be a clue to the issue - I can connect to the database using Querious (mysql database software) but only if I specify using Unix Socket instead of TCP/IP and leave the socket path blank (this using an SSH tunnel). My knowledge in this area is very shaky but I thought it might be worth mentioning in case it helps. I'm using Serverpilot.

Hopefully someone can shine a light?


1 Answer 1


Thanks for your help Brad. After going round and round in circles, deleting the database and setting up a new one sorted it. Ah the mysteries!

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.