简体   繁体   中英

XAMPP - Access denied for user 'michael'@'localhost' (using password: YES). Using a php file to connect to the MySQL

I am getting this error when I try to use a php login page to connect to the database. I have both apache and MySQL running. My apache is listening on port 8080 . I have created a user "michael" with password "17701788" with privileges to all databases using the phpmyadmin interface. I have tried changing the conf.ini file of phpmyadmin but it still didnt work.

This is my dbconnect.php file

<?php
$dbConn = mysqli_connect('localhost', 'michael', '17701788', 'autoservice');
if(!$dbConn) {
    die("Failed to connect to database " . mysqli_connect_error());
}
?>

Check the hostname. You might wanna try 127.0.0.1 instead of localhost. Its the same thing but sometimes things get funny. if this does not work. delete the current created user and create another. this time; 1. be sure not to copy and paste the password especially as it could have white spaces. 2. Enter each credential carefully.

run and lets see.

When the coffee gets finished, stress makes us not see very tiny errors. lol

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM