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);
}
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
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.