Over the last day or so I'm not able to connect to a database through PHP. Here's what my code connecting to the database looks like
$con = mysqli_connect("localhost","root","password","database");
And here's the strange error.
PHP Warning: mysqli_connect(): (HY000/1045): Access denied for user 'user'@'localhost' (using password: YES) in - on line 2
I'd usually get that error if the credentials are incorrect, but I used a GUI and tested the connection with the exact credentials, where therefore means that, that is not the issue. I just started randomly getting this error and have restarted my computer, reinstalled MySQL, and reconfigure the server I've also tried 127.0.0.1
instead of localhost
I'm on localhost
so I have full control on pretty much anything and I didn't mess with anything causing this issue. Any ideas?
For some reason the function is trying to connect using the "user" user instead of "root".
You can debug further by adding the error link:
$con= mysqli_connect("myhost","myuser","mypassw","mybd") or die("Error " . mysqli_error($con))
;