'Failed to connect to MySQL: Access denied for user 'u201944136_root'@'localhost' (using password: YES)
I got stuck at this. i am using hostinger for my website
$server = "localhost";
$user = ""; //Username
$password = ""; //Password
$database = ""; //Database
$connection = mysqli_connect($server,$user,$password,$database);
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
This is my code. i could not find a relevant answer. Thanks in advance.
Solution 1:[1]
thanks for helping me. it was hosting issue. i mailed to the support system of the hostinger. they told me to change my database password and then update the script. i follow the instructions and my error was solved. Thank You All.
Solution 2:[2]
Are you sure that localhost is the right host? I would also dump the mysqli_connect_errno() value because it returns the error code from the last connection attempt, which will give you a very good indication of where the issue is. and I would check if the user u201944136_root is defined and have permissions against localhost (mysql> SHOW GRANTS FOR 'u201944136_root'@'localhost';)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | XtyLish Sam |
| Solution 2 | d3javu999 |
