0

I granted all privileges. This is the script:

<?php
require_once 'login.php';
$conn =  new mysqli($hn, $un, $pw, $db);
if ($conn->connect_error) die($conn->connect_error);
?>

I have this message in the browser:

Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES) in C:\xampp\htdocs\web-datos\connect_mysql.php on line 11

Access denied for user 'username'@'localhost' (using password: YE

I've tried to connect with no success.

How can I solve this problem?

2
  • need to check the values assigned to your username $un and password $pw. Make sure your user you are trying to use is created and the appropriate password is set. Commented Jun 13, 2016 at 2:15
  • Well, i did a mistake with the file login.php with the username just i had to change to 'root' thank you for your advice already solve!!! Commented Jun 14, 2016 at 2:48

1 Answer 1

2

i believe you cannot connect to your mysql database. you need to grant access to username@localhost.

grant all privileges on yourdb.* to username@localhost identified by 'password';

if you have not created the user.you can use this command to create new user.

create user 'newuser'@'localhost' identified BY 'password';

you could also possibly type your user or password wrong.please check it

Sign up to request clarification or add additional context in comments.

1 Comment

yes you have the righ j.Doe, it was it, and indeed that is the only hard way to learn from our own mistakes thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.