I'm seeing an issue where $mysqli = new mysqli($dbhost, $dbuser,'', $db); is giving me Fatal error: Uncaught mysqli_sql_exception: Access denied for user 'user'@'localhost' in /Library/WebServer/Documents/index.php:6 Stack trace: #0 /Library/WebServer/Documents/index.php(6): mysqli->__construct('localhost', 'user', '', 'foo') #1 {main} thrown in /Library/WebServer/Documents/index.php on line 6 although running this file in the command line works just fine. I found a similar thread here PHP: can connect in terminal access denied in browser (Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' , but I'm on mariadb installed with homebrew on macos and the thread seemed to have been resolved by having uninstalled XAMMP, which I don't have installed.
I also tried to pass 127.0.0.1 as my host instead of localhost.
the linked duplicate post has nothing to do with my issue in this post as that post is reporting issues with opening the mysql system client to access a database, whereas I'm reporting issues with not being able to access the database through mysqli on a webserver.