Solved Wordpress can't connect to mysql database

So after reinstalling databases/mysql80-server and the client, everything is back to normal. That is, I'm not seeing weird permission errors in freebsd.err and I can now access the Wordpress installation page. The server stays on and doesn't shutdown by itself. But the problem still remains that the Wordpress page says
Error establishing a database connection

There are no errors in /var/db/mysql/freebsd.err or the nginx error.log. I can only think this is a Wordpress or mysql configuration issue. I see the problem all over the internet but nothing I've tried works. I was hoping someone here would have an idea.
 
Try doing a simple php script to connect, will tell you if issue is mysql config side or wp-side
Code:
<?php
$link = @mysqli_connect('localhost', 'user', 'password', 'database');

if (!$link) {
    die('Connect Error: ' . mysqli_connect_error());
}
?>
 
Back
Top