0

I am running a PHP application that uses a few MySQL databases on Windows 10 (I used IIS to set up PHP). So far, I am getting this error:

mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)

whenever my PHP application tries to automatically connect to PHP. However, this error goes away whenever I log in using the Command Prompt.

Can anyone shed some light on why this happens?

I am using this code to connect:

<?php
  // Define database connection constants
  define('DB_HOST', 'localhost'); 
  define('DB_USER', 'root');
  define('DB_PASSWORD', '');
  define('DB_NAME', 'tutorial');
  define('MAIN_TABLE_NAME', 'users');
  define('THREAD', 'threads');
  define('POST', 'posts'); 
?>

$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die('Could not connect');
  • Does this answer your question? [Warning: mysqli\_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES)](https://stackoverflow.com/questions/25174183/warning-mysqli-connect-hy000-1045-access-denied-for-user-usernameloca) – Jsowa Sep 27 '20 at 22:46
  • I have tried one of the answers: removing the special character from my password. However, that didn't change anything. – MSuccessor Sep 27 '20 at 23:20

0 Answers0