CJB
CJB

Reputation: 300

Access denied for user 'www-data@'localhost

I'm trying to configure a my ubuntu 14.04 server to run my web application that I created awhile ago. It was on a different server than and now I'm migrating it.

So I've put everything in the var/www/html folder

Ran the following in Putty sudo a2enmod rewrite sudo service apache2 restart

Once I go to my actual website I get the following error message

SQLSTATE[28000] [1045] Access denied for user 'www-data'@'localhost' (using password: NO)

If I go directly to the .htaccess redirect file I can get to the first page fine, its when I try to do anything with the database it seems to fail.

The user I created has enough access to login or register a new user on the site etc, but this error is stopping me.

Upvotes: 0

Views: 1088

Answers (2)

CJB
CJB

Reputation: 300

Had to modify config.php as it was missing mysql user credentials, hence why it was searching in the www-data group which had no password.

Upvotes: 0

paullb
paullb

Reputation: 4335

This is an SQL issue. Nothing to do with your .htaccess.

Use "show grants" on my SQL server (assuming it's mysql) to see what users have access to what.

Here are some examples of possible issues:

Your error indicates you didn't pass a password.

  • Does this user require a password to access sql?
  • Does the user www-data exist?
  • Does the user www-data have the ability to access from localhost.

Upvotes: 1

Related Questions