Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘dbuser1’@’localhost
This is probably something stupid, but I created some code to access my database from a PHP script but there was an error (dbuser1 doesn’t exist) at the first run and now its stuck with the same error even if I change the username to another one. I’ve even renamed the PHP file, uploaded it, and ran the new file with different name and the error is the same (still showing old name dbuser1 instead of dbuser1000). I’m new to web development so maybe I’m just misunderstanding something. I’m using Bluehost shared.
You have to grant access permissions in MySQL to the username you’re using within your PHP code
If your PHP code looks something like this:
Then you’d have to do the following in MySQL to grant permissions to this account:
If you’re connecting to a remote MySQL instance, then you have to grant permissions to the host you’re connecting the PHP script from, etc… Full details are on the linked MySQL doc page above.