An application was handed to me by an old colleague to manage. However, whenever I try to run it, I keep getting this error. Please any help would do.
-
Either the username or password used in the code is wrong, or the database permissions for that user don't allow access. – Barmar Jul 30 '14 at 08:20
11 Answers
Sometimes Access denied Exception Error because your mysql credentials are invalid. Secondly, from my experience i observed that this also happens because you did not set password to your database connectivity. eg
private $host = "localhost";
private $db_name = "db_dbtest"; // Database name
private $username = "db_user"; // your database username
private $password = "db_password"; // Your password
public $conn;
}
Try and set password to your database connectivity. I had such experience and after changing my Collation to utf8_general_ci on the Operations tab, this could not solve my problem. I thought of adding password to my database connection and immediately it connected. You can tesrun this and see if it helps.

- 66
- 1
- 3
You're getting Access denied Exception Error because your mysql credentials are invalid.

- 321
- 3
- 7
This is due to the wrong sql information provided by you.Changing it to the right one can solve this error .

- 6,171
- 3
- 21
- 26
I was getting this same error code. I'm using phpMyAdmin and added the database with the import of a sql file. The website was using all the same code that had worked before. To fix this error go inside phpMyAdmin and click on the database then operations tab. Change the collation of my database to "ut8_general_ci". Afterwards it was able to verify the username/password access to the database.
Also you might want to make sure you added the user accounts tab the username,password and privileges to access the database.

- 11
- 1
I know this is an old question, but for me I had to set my password in Sequel Pro to the password that was listed in my .env config file. Hope this helps someone!

- 41
- 6
Well it means the SQL credentials you are using are wrong there is nothing much we can do, you need to use the correct ones or use the root account to change the user's password or rights.

- 3,680
- 5
- 35
- 40
-
i have little or no idea as how to change this. I use xamp server. how do I get to do this? – segdavids Jul 30 '14 at 08:25
-
I am also using xampp and had the same problem. Ran the query "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');" and everything started to work – jose Jul 14 '17 at 16:35
The first thing you should check is your credentials. I thought i had root
as username and password but when i looked in the file C\xampp\phpMyAdmin\config.inc.php
under
$cfg['Servers'][$i]['password'] = 'WhateverPassword';
I saw that i had a different default password. You should use or change the password that is in that file when trying to connect to your database.

- 1
- 1
You have to specify the port you are using for your MySQL. for me, I was changed the port of MySQL like 3307. example:localhost:3307

- 1
Make sure you have the right credentials and these are being passed to the database connection command.
Also make sure to either wrap the credentials in single quotes '
or escape them with backslash \
, as there are some special characters not recognised. Hope this helps someone. Here's a reference:
String Literals

- 48
- 7
First I would suggest trying all the above solutions. In my case, they didn't work and my username and password are all correct. I followed the guide by digital ocean on installing LEMP stack and encountered the same error. And the following solution worked for me.
After first uninstalling mysql following this guide. I then installed mysql again but skipping the command
$ sudo mysql_secure_installation
The direct error caused by this line could be easily fixed by Step 2 in this guide. But turns out that this line of code leads to potential authentification issues, which is causing the same error message presented by you.
Hope this helps.

- 1
- 2
The site you got handed has the login credentials for your colleague's machine/site. Depending on the site, different files need to be changed. Example, Wordpress usually has the settings in a file called wp-config.php
Until you find this file, maybe you can change your XAMPP user login to match. This article on SO tells how to change SQL login credentials:

- 1
- 1

- 2,185
- 1
- 20
- 22