Lance Deal
Lance Deal

Reputation: 13

Cannot connect Xampp server with PHP script

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?

Upvotes: 0

Views: 351

Answers (1)

j.Doe
j.Doe

Reputation: 172

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

Upvotes: 2

Related Questions