Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) Could not connect database

Related searches

I'm having problems by connecting to my database which was created on phpmyadmin... I'm using MAMP as a local server. I've checked several things even the "config.ini.php" file, and the data there matches with the "user" data of my database, plus the "user" has all privileges granted. I even tried different alternatives as hostname: localhost, localhost:3306, 127.0.0.1... even my own ip.

I'm quite lost now... any ideas? Here's the code:

<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "mypassword";
$mysql_database = "mydatabase";
$prefix = "";
$bd = mysqli_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysqli_select_db($bd, $mysql_database) or die("Could not select database");
?>

Go to your PHPmyadmin and run the below query in Mysql DB

GRANT ALL PRIVILEGES ON yourdbname.tablename TO 'user'@'localhost';

After that run the query, FLUSH PRIVILEGES

You can also try GRANT USAGE ON yourdbname.tablename TO 'user'@'localhost';**** After that run the query, **FLUSH PRIVILEGES

If you still cant access you can once verify in the users tables if there is no N on any of the privileges.

How to Fix " Warning: mysqli_connect(): (HY000/1045): Access , How to fix php error "Warning: mysqli_connect(): (HY000/1045): Access denied for user Duration: 3:01 Posted: Dec 20, 2019 Access denied means that the authentication failed. That means there is an invalid username or password combination. For SQL, it's obvious that the user can be root. So please go to your phpMyAdmin and check from the users tab.

Note: it should follow the sequence : 1. host name 2. user name 3. password 4. database name

This is important while writing, so it should be written as follow.

<?php 
$hostname = "localhost"; 
$username = "root"; 
$password = ""; 
$database = "akshata"; 

$data= mysqli_connect($hostname,$username,$password,$database); 
if($data) {
 echo "database connected"; 
} else {
 echo "database not connected"; 
} 

?> 

Warning: mysqli_connect(): (HY000/1045): access denied for user , The first one is quite clear: You have passed invalid credentials (user name and/ or password) when trying to connect to the database. What to� Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'loc Stack Exchange Network Stack Exchange network consists of 177 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Well did you set a passwort? or created a User?

If not just try

$mysql_hostname = "localhost";

$mysql_user = "root";

$mysql_password = "";

$mysql_database = "mydatabase";

The basic on Wamp/Xamp is that (for me, i think for everyone?) If i missunderstood the Question, I'm sorry!

[Solved] How to solve mysqli_connect(): (HY000/1045): Access , 4 - I set users access and rights to "employee101" DB. 5 - I built two PHP Warning: mysqli_connect(): (HY000/1045): Access denied for user� Maybe the database you are trying to access it has been created by another user/with a different password or you don't have permission to access the database. Check the details in cPanel > MySQL Databases.

(HY000/1045): Access denied for user 'root'@'localhost' (using , When I upload the database on GOdaddy.com, this error shows up. Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using � Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) Hot Network Questions How to appropriately email a researcher to ask for details about his/her paper?

Warning: mysqli_connect(): (HY000/1045): Access , Warning: mysqli_connect(): (HY000/1045): Access denied for user ''@'localhost' ( using password: NO) in E:\xampp\htdocs\nafeekuet\src\app\Database.php on� Warning: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES) in C:\Users\xampp\htdocs\PHP_Login_Script\config.php on line 6 Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given in C:\Users\xampp\htdocs\PHP_Login_Script\login.php on line 10

Warning: mysqli_connect(): (HY000/1045): Access denied , Warning: mysqli_connect(): (HY000/1045): Access denied for user '<root>'@' localhost' (using password: YES) in F:\xampp\htdocs\includes\libs\DbSimple\ Mysqli. How to fix phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection - Duration: 2:28. Jhon Smith 51,927 views

Comments
  • MariaDB? Dont use root user.
  • Just a bit of a side note here: You should use a more precise variable for the connection. The "bd" was a bit misleading for me, since those 2 letters are often used as the French version of "base de données", which means "database" in English. I thought you had that database declaration as the 1st argument. So you can see how it can be a tad confusing.
  • You need to find out why exactly it failed you by using mysqli_connect_error() secure.php.net/manual/en/function.mysqli-connect.php
  • It's 3am here so I'll check that function tomorrow... thank you!
  • <?php $hostname = "localhost"; $username = "root"; $password = ""; $database = "akshata"; $data= mysqli_connect($hostname,$username,$password,$database); if($data) { echo "database connected"; } else { echo "database not connected"; } ?>
  • I created 1 user with its respective password and also gave a password to "root"... the one that I use on my code is the one that appears described on the "config.ini.php" file, which is the same one where I gave a password to "root"...
  • did u think about using myadmin and create the user there?
  • I created the users on phpmyadmin after creating the database.
  • I just checked after on the config.ini file to see if everything was equal
  • hmmm could you make a screen or something of your myadmin users?