Reputation: 161
Whenver i go to locallhost/Blog/app/DB i encounter this error. I have tried so many times to connect to the database but could not connect. Even if i use my mysql password which is "root" this does not work.Please someone help me Here is my connection code:
host = "localhost";
$username = "root";
$password ="";
$db_name ="blog";
$conn = new mysqli($host, $username, $password, $db_name);
if($conn->connect_error){
die(' Database connection error '.$conn->connect_error);
}
This is my phpmyadmin user account:
Upvotes: 1
Views: 1773
Reputation: 1461
As Indra said, avoid using root
. This account should only be used by a human, even in a development environment. If you need an account that has complete and total access to everything, create one:
CREATE USER 'indra'@'localhost' IDENTIFIED WITH mysql_native_password BY 'superSecretPassword!123';
GRANT ALL ON *.* TO 'indra'@'localhost' WITH GRANT OPTION;
The root
account in MySQL should only be used when you are configuring replication or fixing something what went really, really wrong 🤐
Upvotes: 1