将数据库文件连接到 myphpadmin 时,myphpadmin 出现错误

问题描述 投票:0回答:1

我有一个用 PHP 和 MYSQL 编写的项目,我在 MYPHPADMIN 数据库中导入了数据库文件,但在这期间我收到了此错误

在此输入图片描述

任何人都可以解释错误并给出解决方案吗

由于 root 密码而显示一些错误,即使在 MYPHPADMIN 中创建了一个新用户并更新了数据库文件中的密码,我也更改了 root 密码,然后也出现了错误

`$hname = 'localhost';
  $uname = 'root';
  $pass = '123456';
  $db = 'hbwebsite';

  $con = mysqli_connect($hname,$uname,$pass,$db);

  if(!$con)
  {
     die("Cannot Connect to Database".mysqli_connect_error());
  }`

这是我写的代码

db_config.php

在此输入图片描述

这些是用户帐户。即使用户名和密码正确,我还是收到错误

php mysql database phpmyadmin
1个回答
0
投票
There may be a certain reason not connecting with DB, Check Database log into phpMyAdmin with the credentials you're using in your PHP script and ensure that the database exists and is accessible or not.

Error Output: If you encounter an error, note what it says. Common errors included
Access denied for user (wrong credentials)
Unknown database (the database doesn’t exist)

you can getting Access denied for root and other user's seems permission not granted ,try below command

    CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'newpassword';
    GRANT ALL PRIVILEGES ON hbwebsite.* TO '<newuser'@'localhost';
    FLUSH PRIVILEGES; 

or try to restart mysql once.

Make sure to go through each of these steps. If you’re still having issues after checking everything, feel free to provide the exact error message, and I can help you further!
© www.soinside.com 2019 - 2024. All rights reserved.