I am trying to write a php script which displays a database on a website and I can't figure out why it will only accept the root user as a login. If I put any other user in the script it will just say access denied.
The user I am trying to use has all privileges granted on that database.
+-----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for user@localhost |
+-----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' IDENTIFIED BY PASSWORD '' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `my_db`.* TO 'user'@'localhost' WITH GRANT OPTION |
+-----------------------------------------------------------------------------------------------------------------------------------------+
<?php
$servername = "localhost";
$username = "root";
$password = "Password";
$dbname = "my_db";
$mysqli = new mysqli( $servername, $username, $password, $dbname );
if ($mysqli->connect_errno){
printf("connect failed: %s\n", $mysqli->connect_errno);
exit();
}
$rs = $mysqli->query( "SELECT * FROM table ORDER BY device_name ASC;" );