-2

I'm building a website with a login using php and mysql. When I try to connect to the database I keep getting error:

Notice: Could not connect to MySQL: Access denied for user 'User'@'localhost' (using password: YES)

I have tried to set a new password or no password but keep getting this error. Does somebody know how to fix this?

I noticed this error also occurs when using mysql with java apps

I'm using phpMyAdmin with wamp

Edit: Here is the code. I replaced Username, Pass and Database by User, Pass and Database

DEFINE('DATABASE_USER', 'Username');
DEFINE('DATABASE_PASSWORD', 'Pass');
DEFINE('DATABASE_HOST', 'localhost');
DEFINE('DATABASE_NAME', 'Database');
date_default_timezone_set('Europe/Brussels');

DEFINE('EMAIL', 'user@email.com');

DEFINE('WEBSITE_URL', 'localhost/wadistjom');

$dbc = @mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME);

if (!$dbc) {
   trigger_error('Could not connect to MySQL: ' . mysqli_connect_error());
}
Maarten Meeusen
  • 482
  • 1
  • 9
  • 23

2 Answers2

0

If you are using PhpMyAdmin then you should be able to see all users under the "Users" tab on the PMA startpage. You can also create a new user there.

Lyckohjul
  • 23
  • 4
0

Have you made sure remote access is on for each user? Sounds like that could be an issue (especially if you're having the same issue with Java applications).

This could should work:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Pa55w0rd' WITH GRANT OPTION;

(yanked it from How to grant remote access permissions to mysql server for user?)

Community
  • 1
  • 1
code4coffee
  • 677
  • 4
  • 13