0

I have probably an incredible stupid question...

I have the following code, it should work. All credentials are working, I tested them with a different script. But, I cant see where the code is wrong...

Could someone be so kind to help me in finding the problem, so I can understand it better?

define("HOST", "localhost"); // The host you want to connect to.
define("USER", "deb63058_DomiSec"); // The database username.
define("PASSWORD", "ypPN7UY6aaxLxw7D6qwTrkJ3"); // The database password. 
define("DATABASE", "deb63058_Domi"); // The database name.

$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE) ;
// If you are connecting via TCP/IP rather than a UNIX socket remember to add the port number as a parameter.

$con=mysqli_connect("localhost","deb63058_DomiSec","ypPN7UY6aaxLxw7D6qwTrkJ3","deb63058_Domi");

if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL !!!: " . mysqli_connect_error();
  }

Give's the following error:

Failed to connect to MySQL !!!: Access denied for user 'deb63058_DomiSec'@'%' to database 'deb63058_Domi'

What does '@'%' mean in the error message? I connect to a local turnkey linux server

2
  • Access denied for user is a simple username/password error message - check your username and password. Normally that would say : Denied for user 'deb63058_DomiSec'@'localhost' though. ... I hope none of those connection details are really, real though (on a public website like SO) Commented Oct 4, 2013 at 13:26
  • ... oh, also check your mysql.user and mysql.tables_priv tables to ensure that your user has access rights to the deb63058_Domi table Commented Oct 4, 2013 at 13:30

1 Answer 1

3

'deb63058_DomiSec'@'%' means the user has been created so that it can access the database from any host. % is a mysql wildcard. The error Access denied for user 'deb63058_DomiSec'@'%' to database 'deb63058_Domi' indicates that the password is correct, but the user does not have access to that database. Check the privs for that user within mysql with this command: SHOW GRANTS FOR 'deb63058_DomiSec'@'%'; Then add the necessary privs that you need.

Sign up to request clarification or add additional context in comments.

1 Comment

Just checked it in MySQL Workbench, your absolutely right! Thank you very much aynber, I was seeking the error in PHP...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.