Search code examples
phpmysqldatabase-connectivity

Linux connecting to mysql PHP


I have been trying to connect to mysql all evening using PHP. I know for a fact the username and password are correct as I have tried 3/4 and I know the permissions are set correctly in the database.

If I remote onto this machine and enter the exact same details into the commandline then i can connect to the database without issue.

The problem only seems to be with MYSQL and PHP.

A little more info:

I am trying to run a PHP app on the same server as the mysql database is on. The user has full grant permissions on the local machine. The error i am receiving is :

Fatal error: Attempt to connect to database kmc_cms on

The server is set so no remote access to mysql is available.


Solution

  • I found out the issue. Within the mysql database config file there was an error which resulted in the connection allowing users from local host access only. Even though the PHP scripts were connecting using localhost it just would not authenticate. Hence I could log in using command line and not using PHP or other applications.