Mysql Connection Error

Hi,
I can’t connect to my database,
Failed to connect to MySQL: Access denied for user ‘epiz_25716775’@‘XXX.XXX.2.XX0’ (using password: YES)

Using this script,

try{
    $conn = new mysqli($host, $user, $pass, $dbname);

    if ($conn -> connect_errno) {
        echo "Failed to connect to MySQL: " . $conn -> connect_error;
        exit();
    }       
    //echo "connection success";
} catch(Exception $e) {
    echo "Connection failed."; 
}   

I was able to connect in database admin and upload my tables but when I try it on my page, it does not work.
Is my permission okay?

Thank you!

Hello there,

Where are you trying to connect to your MySQL database? Are you trying to connect to it from an external application or just in your site?

You can also refer to this KB article:
https://support.infinityfree.net/MySQL-Databases/common-mysql-errors/

2 Likes

Hey, thanks for that helpful information.

The most common issue is that people are not using the right database password. You should use the hosting account password in your script configuration.

This one is my error and was able to fix it. Thank you and keep safe!!

1 Like

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