1

I tried using the following code in php:

<?php
$servername = "www.psgcirdask.com";
$username = "xxx"; //hidden for security purpose
$password = "password";
$dbname = "psgcilqh_calibration";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
 // Check connection
  if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

  $sql = "SELECT * FROM brands";
  $result = $conn->query($sql);
$conn->close();
?>

I got an error:

Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'xxx'@'157.51.147.43' (using password: YES) in C:\xampp\htdocs\justshawarmapos\checkthedatabase.php on line 9 Connection failed: Access denied for user 'xxx'@'157.51.147.43' (using password: YES)

But i use the same username and password to connect to my database in my website.I am getting this problem only when i connect using local server.

2
  • Your web site does not connect from 157.51.147.43, does it? Commented May 30, 2018 at 12:52
  • Yeah this is my ip address Commented May 30, 2018 at 12:59

2 Answers 2

1

You have to enable remote access in your mysql database.

Check this link

For hostgator

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

11 Comments

How do i do that?
@NikeshhBaskaran maybe serverfault.com/questions/52794/… helps
My website is on hostgator.How to do it there?
That's even easier from hostgator cpanel : google.co.in/url?sa=t&source=web&rct=j&url=https://…
I added my ip address 157.51.171.108 in the remote access but still i get the same error
|
0

Check if all the infos provided are correct especially the servername then try to figure out if you have the right permission to access that database with that user!

Comments

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.