Search code examples
phpmysqlsymfony1

Why PHP MySql connection do not work?


I'm using MySQL given from A2Hosting. There I can create users and add them to databases. And i hosted my php codes inside web folder in symfony php structure. I dont want to use any symfony commands or functions. I have my own php calls to DB. But my Php codes gives the following error. But the user names and passwords are correct.

Query failed : Access denied for user 'games_user'@'localhost' to database 'games'


Solution

  • Granting privileges to user 'games_user' could not be enough. You must grant privileges to 'games_user'@'localhost', specifiying the host, even for localhost.

    Granting all privileges for instance should look like this:

    GRANT ALL PRIVILEGES ON database.* TO 'games_user'@'localhost' IDENTIFIED BY 'password';