Ant Ant - 1 year ago 70
MySQL Question

Not able to connect to DB when site uploaded to Plesk Panel

So, I have a very simple php configuration file to connect to a MySQL Database, called

inside a folder called
, which is included in all the pages that require access to the Database.
I have a user (let's call him
) created with the database (let's call it
) from within my plesk panel.
Now when I try to access a database, through a custom login page that simply checks
to see is username and password are a match, I get the following error logs:

[Wed Jun 11 23:21:59 2014] [warn] [client] mod_fcgid: stderr: PHP Warning: mysql_connect(): Access denied for user 'db_user'@'localhost' (using password: YES) in /var/www/vhosts/~sitename~/httpdocs/modules/connect.php on line 2, referer: http:// ~sitename~/admin/login

[Wed Jun 11 23:21:59 2014] [warn] [client] mod_fcgid: stderr: PHP Warning: mysql_select_db(): Access denied for user ''@'localhost' (using password: NO) in /var/www/vhosts/~sitename~/httpdocs/modules/connect.php on line 3, referer: http:// ~sitename~/admin/login

[,,,] (more messages essentially saying it has not connected and as a result are trying to connect with no username and password)

file is:

mysql_connect('localhost', 'db_user', 'password');

Here are the
SHOW GRANTS FOR db_user@'%';

##Grants for db_user@%##

GRANT ALL PRIVILEGES ON `db_user`.* TO 'db1'@'%'

Mind that everything is running smoothly on my MAMP configuration back at my workstation, so I doubt there is any code related issue.
So, I have run out of ideas on what I could try to solve this...
Any suggestion would be very appreciated!

Ant Ant
Answer Source

Apparently in the database section there is a column named Database server which gives the address of the database, which in my case simply was not localhost, or anything like that!

I changed the address and off it worked!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download