php5 and MySQL 5 – Access Denied

Permissions problem kept php5 and mysql 5 from talking….

When setting up a test website using Apache 2, php5 and mysql5, the connection to the database failed with AccessDenied. If the password were removed, then the failure looked different. The resolution to the problem is to include localhost explicitly in the host list and set database privileges for localhost. The default is @% which is wildcard, but apparently wildcard does not include localhost.
For a complete description, screen shots and the whole story:

Here is the MySQL Admin screen for users.
To add a host, select the user and right click. Then choose Add Host and choose localhost.
Then set the privs for that connection. Select localhost and go to the privileges tab.

Select all the privileges in the right list and click the (< ) button to move the privs to the allowed list.


Now, php5 and mysql5 will play nice together under apache. So for example you can install WordPress.