1
votes

I have recently started exploring free hosting sites where they provide free mysql and php.

I have created a database and trying to connect to the database from php script. But while running the php. I am getting following error :

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'a1696486_test '@'localhost' (using password: YES) in /home/a1696486/public_html/myphp/test1.php on line 2

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'a1696486'@'localhost' (using password: NO) in /home/a1696486/public_html/myphp/test1.php on line 3

Any idea whats the problem ?

Regards, Shankar

1
Wrong user or password? Can you show the code you use to connect? why are there 2 different users?Damien Pirsy
try root user. if works then problem in creating user or granted rolesSubdigger

1 Answers

2
votes

I have this issue on our dedicated servers, and the solution for me is to provide the fully qualified domain name rather than 'localhost'. For exmaple, my connection is:

mysqli_connect('dedi81.jnb1.host-h.net', 'user', 'pass', 'db');

Where even though localhost is the same as dedi81.jnb1.host-h.net (MySQL server and web server on one machine) I - for some reason - cannot use 'localhost'.

Another issue may be that on the hosting company you're with, they have not granted to you the correct permissions, or that there is indeed an error with the username and / or password.

You can also try and substitute 'localhost' with the IP address of the MySQL machine.

Kind regards, Simon