Home  >  Q&A  >  body text

Title rewritten to: WARNING: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: yes)

<p><br /></p><blockquote> <p>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 </p> ; </blockquote> <p>I get the above error on localhost even though my config file looks like this: </p> <pre class="brush:php;toolbar:false;"><?php define("DB_HOST", "localhost"); define("DB_USER", "root"); define("DB_PASSWORD", ""); define("DB_DATABASE", "databasename"); $db = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);</pre> <p>This used to work, but no longer does. Is there something wrong with this code, or does it not work now? </p>
P粉667649253P粉667649253448 days ago462

reply all(2)I'll reply

  • P粉933003350

    P粉9330033502023-08-22 09:31:28

    If you are using wamp, please update

    define("DB_HOST", "localhost");

    Change to your machine IP address (mine is 192.168.0.25);

    define("DB_HOST", "192.168.0.25");

    You can find it by typing ipconfig in the console on Windows or ifconfig on Mac/Linux.

    reply
    0
  • P粉505450505

    P粉5054505052023-08-22 00:50:31

    This username, host and password combination does not allow connection to the server. Please verify the permissions table on the server (reload authorization if necessary) and make sure you are connecting to the correct server.

    reply
    0
  • Cancelreply