I am trying to connect to a mariadb database using PHP without success. Each attempt I get the following:
Error: Unable to connect to MySQL. Debugging errno: 1045 Debugging error: Access denied for user 'gt_user'@'localhost' (using password: YES)
I have tried all many attempts. Have even reverted to a simple index.php test which never connects.
Connecting from the command line with the same user credentials works fine
mysql -u USER -p -h localhost database
I have even tried giving the user all privileges as well as created the same user with @'%' rather than @'localhost'
Here is the simple test php code I am trying:
<?php
$link = mysqli_connect("localhost", "gt_user", "passpass", "gt_monitor");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
mysqli_close($link);
?>
I have also tried from browser on local host as well as remote. Same error.
Im thinking it has to do with missing dependencies. Not sure how to thoroughly check. Running PHP 7.0.33 and mariadb 10.1.37 on Raspberry pi on latest Rasbian Stretch.