Error establishing a database connection

I’ve setup everything up according to

However, I’m having similar issues as this thread.

I’m able to ssh into vagrant and see the database using cmds below, but no joy when trying to connect via browser.

ssh vagrant
mysql -u <my_username> -p
show databases;

Warning: mysqli_real_connect(): (HY000/1045): Access denied for user…

Error establishing a database connection

Any input would be greatly appreciated.

Thank you. bkc

Still no luck with this. The issue appears to be that the new WP site is trying to login to the existing homebrew MySQL install @ localhost.

I don’t have much experience with Vagrant or MariaDB, but should there be a port to point bedrock’s wp install to the Vagrant MariaDB? What directs the WP site to the new MariaDB in the Vagrant VM?

If it’s trying to connect to mysql on the host instead of the vm then you probably have a conflict/duplicate entry in your hosts file on the host machine.

2 Likes

That did it! I overlooked the step in vagrant up which wrote to /etc/hosts. Removed the entry I already had for this domain and we’re in business.

Thx for your input! bkc

I got the same error message, but for a different reason. I had a multisite WP with wp_home as http://www.mysite.dev, wp_siteurl as http://www.mysite.dev/wp, but domain_current_site as mysite.dev, without “www.”. I removed “www.” from wp_home and wp_siteurl, which fixed the issue (I could have just as well added “www.” to domain_current_site). Just make sure they match.