Database access denied

Website URL

http://infinitytest.infinityfreeapp.com/php/conn.php

Error Message

Connection failed: SQLSTATE[HY000] [1044] Access denied for user ‘epiz_33752893’@‘192.168.0.%’ to database ‘epiz_32752893_db1’

Other Information

I have seen someone mentioned php configuration, but I don’t know how and where to set it.

You’ll need to find where in your code the connection is being form, and by having a quick look in http://infinitytest.infinityfreeapp.com/php/ without any knowledge of your code, I think it’s entirely possible it’s done in the file you linked (conn.php).

4 Likes

I tried different codes indifferent styles, but none of them was able to access the database.

<?php
$servername = "sql313.epizy.com:3306";
$username = "epiz_33752893";
$password = // password
$database = "epiz_32752893_db1";

try {
  $conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);

  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  echo "Connected successfully";
  } catch(PDOException $e) {
  echo "Connection failed: " . $e->getMessage();
}

// Close connection
$conn = null;
?>

check if the DB with that name exists ! (epiz_32752893_db1)

if you get 1044 then the DB name is the problem
if you get 1045 then the password is a problem

6 Likes

You are right.
There is a wrong digit in the username part of the database name. Stupid me.

Thanks to you two!

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.