Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why is my localhost turned into a percentage sign

I am trying to connect to a remote database and the credentials are correct but I get an error and I would like to know why ‘localhost’ is turned into a % sign and why I am unable to connect. If I use the full remote URL of the database the same thing happens.

Here is my php page:

<?php
$DATABASE_HOST = 'localhost';
$DATABASE_USER = 'testuser';
$DATABASE_PASS = 'password';
$DATABASE_NAME = 'table';


$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if (mysqli_connect_errno()) {
  die('<div class="error">Failed to connect to MySQL: ' . mysqli_connect_error() . "</div>");
}
if (!$con) {
  echo "<div class='error'>Not connected</div>";
}

The error I get looks like this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Failed to connect to MySQL: Access denied for user 'testuser'@'%' to database 'table'

Why is localhost or the full remote address turned into %

>Solution :

The nearest user record in MySQL that matched the username you provided was the MySQL user 'testuser'@'%'. It’s not that you provided that name, it’s that this is the user record in MySQL. And while the password for it was apparently okay, that user has not been granted permissions for the table database.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading