Can't connect to database

I’m trying to create a new wordpress site and keep getting stuck on the database connection, error code DK0033. I’ve looked at the help page for this error and it didn’t help as I don’t have a wordpress db to export. I’m running windows 10 home, docker desktop is up and running, I’m using WSL 2 and have created a .wslconfig file.

Welcome to DevKinsta @rawsienna . I’m happy to help.

Is the WordPress site that you’re creating one that’s been imported from Kinsta, or an entirely brand new WordPress site within DevKinsta? If you haven’t already, update to DevKinsta 2.2.0. Let me know if this helps!

Thanks for getting back to me, it’s a brand new site

I ran into a similar issue although not sure the solution would be exactly the same for your case.

TLDR; The database configuration for root out-of-the-box is wrong…

(This is a really bad first expirience with getting DevKinsta setup)

Verify

To verify this I did the following:

# access the database container
docker exec -it devkinsta_db bash

# in the container, try to login provided credentials
mysql -p

The result was:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Resolve

The resolution was to set the root password using mysqladmin:

# access the database container
docker exec -it devkinsta_db bash

# set root password (use password provided in DevKinsta UI)
mysqladmin -u root password

# verify you can now access the database
mysql -p

# print the databases (optional)
show databases;

EDIT: I ran into further issues with the database configuration out-of-the-box.

The database user access is limited to localhost but because of how the infrastructure/network is setup that means that no other service can access it. When it creates the website it says it was successful but then you run into a few issues:

  • WordPress - “Error establishing a database connection”
  • Adminer - “SQLSTATE[HY000] [2006] MySQL server has gone away”

Resolve

To resolve this you need to grant access from other hosts (in this case they are containers). None the less it’s fairly straightforward:

# access the database container
docker exec -it devkinsta_db bash

# login to mysql
mysql -p

# show access
show grants for 'root'@'localhost';

# copy the one that starts with "GRANT ALL PRIVILEGES" replace `root`@`localhost` with `root`@`%`
GRANT ALL PRIVILEGES ON *.* TO `root`@`%` IDENTIFIED BY PASSWORD '{ENCODED_PASSWORD}' WITH GRANT OPTION;

Now simply click “Retry” in the UI and it should get pass the error.

1 Like

Hello @jromero_arro, welcome to DevKinsta!

Thank you for the detailed explanation on how you got this working. I haven’t seen this issue come up before when testing on both Mac and Win 10 Pro but your provided solution will definitely be valuable for anyone running into the same issue.

Thanks again!

Had the same problem and the error “ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’” I uninstalled devkinsta and docker and then reinstall them both.

it fixed the problem for me.

Hi @Asad_ullah :wave: Welcome to our Kinsta Community!

Thanks for sharing your experience with resolving the ERROR 1045 (28000): Access denied for user ‘root’@‘localhost . It’s great to hear that uninstalling DevKinsta and Docker and then reinstalling them both fixed the problem for you. Your solution will be very helpful for others who may encounter the same error. :+1: