Warning: mysqli::__construct(): (HY000/1045): ProxySQL Error: Access denied for user 'root'@'2a02:4780:bad:f00d::18' (using password: NO) on line 12

Viewed 9127

I have created a basic page with php and MySQL, but somehow i seem to be getting this error. I Have tried entering my MySQL server password but it shows the same error anyway. I am hosting this page from 000webhost and i have just been introduced to coding.

 <?php
    $username= filter_input(INPUT_POST,'username');
    $password= filter_input(INPUT_POST,'password');
    if (!empty($username)) {
        if (!empty($password)) {
            $host = "localhost";
            $dbusername = "root";
            $dbpassword = "";
            $dbname = "project";

            //create connection
    $conn = new mysqli($host, $dbusername, $dbpassword, $dbname);

    //check connection
    if(!$conn)
    {
     die("connection failed: ". mysqli_connect_errno());
     }
     else{
     echo "Connected successfully";
      }

        }
        else{
            echo "password should not be empty";
            die();
        }

        }
    ?>
4 Answers

Follow these steps:

  1. Make sure database password not contain * special character.
  2. Make sure your database name and database username are correct.
  3. Delete all files from /bootstrap/cache except .gitignore.

Make your database in Database Manager first (in 000webhost). Then, change your $dbusername, $dbpassword, and $dbname as provided by 000webhost.

Make sure you are using correct value for $host, $dbusername, $dbname, $dbpassword from the database you want to connect. Please refer to the image below:

enter image description here

If you use 000webhost, just change the database password in the database manager menu until the connection is successful. This is usually because the password contains prohibited characters.

Related