开发者

Error while connecting to mysql database from php

开发者 https://www.devze.com 2023-03-22 09:49 出处:网络
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 开发者_G

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 开发者_Go百科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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消