PHP Database error

Asked

Viewed 280 times

3

I uploaded my website (using Filezilla) using php/mysql. On the localhost it works perfectly but on the external server it doesn’t. The following error appears:

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost

<?php

try {
    $pdo = new PDO ('mysql:host=localhost;dbname=***', '***', '***');
}
catch (PDOException $e) {
    exit('Database error.');
}
?>

What could be missing?

  • Is there an error message? Or the result is a blank screen?

  • Thank you, I edited my question

  • Can you explain the line in which there is the connection statement to the database? You can also check if the connection data is pointing to the credentials provided by your hosting provider?

  • Changes the location of the bank, should ta as localhost, when you move up the application, have change, and put the external link of the bank.

  • I put it on top, and I think I already know. Must have something to do with "mysql:host=localhost"? but what instead?

  • In place of exit('database error') let print_r($e)) this will give the error message.

  • On the external host you need to give root user access or create a certificate. Here has a similar question.

Show 2 more comments

1 answer

3


The message indicates that access has been denied to the user root in localhost.

This means that your host is correct, and you are getting there at the bank, but it is not recognizing as valid your bank and/or user and/or password.

Check with the provider the correct Mysql access data and enter in the fields.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.