Search code examples
phpmysqlapachelaravelpdo

Apache, PHP, MySQL, PDO, Permission denied , laravel


I'm working on a fun little PHP web application (a manager for my repeating, daily tasks), mostly for the exercise. The 'production' server is a bit limiting, and I cannot view httpd's (Apache's) error logs there, so I've set up my own local httpd as a development server (just good sense). However, my web app makes use of a MySQL database. I will create a local one eventually, but I thought, to make things easier to start, I would just use the remote one. SQLSTATE[HY000] [2002] Permission denied.

This is what came back each time I tried running the web application from my local httpd. I'm using PHP's PDO database interface, and its mysql driver, and it works when deployed on the remote server. I made sure that my remote server had permissions for my local user. I tested connecting from my local machine from the mysql client, and it worked. I tested the PHP connection statement from the command-line and ... it worked. It is only causing a problem when running within the web application.

Please tell me how to solve this issue. This is the site on which i am getting error pickprogress.com


Solution

  • Some various server provider gives us their database server name. And instead of writing localhost or 127.0.0.1 we have to write their given server name.

    I was trying to solve this problem since last 8 hours but didn't found single solution but anyhow I have now solved it.