Access denied for user 'root'@'localhost'

nagahysa Posted messages 1 Status Member -  
jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention   -
Bonjour,
If I am asking for help, it's because I am creating a website for my future start-up.
But I have a problem: as soon as I created my page verification.php

verification.php: https://mega.nz/#!hzo0TLqY!scpwFupMlH4e1Cj418hKwyYfDW2euuxncC9ZQx5RESo

I get an error message.
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\verification.php on line 10 unable to connect to the database

Line 10:
$db = mysqli_connect($db_host, $db_username, $db_password, $db_name)


But despite searching on the internet... I still haven't managed to solve this problem.

Please help me.

1 answer

jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention   4 830
 
Hello,

I assume you are working LOCALLY on your computer....
What have you installed? xampp? Wamp? Uwamp? Mamp? easyphp?

Have you tried accessing phpmyadmin with those same credentials?
What password did you use?
Generally, by default, it's root or empty.
If none of these passwords work, you'll need to try resetting the mysql password.
In a command prompt:
 $ mysql -u root mysql 

then, once the mysql console has started..
 $mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root'; $mysql> FLUSH PRIVILEGES; 

You can also try changing the hostname: instead of 'localhost' you can try using '127.0.0.1'

--
Best regards,
Jordane
0