访问被拒绝用户

时间:2012-07-15 18:24:35

标签: php mysql

我已经创建了一个php脚本来访问我的数据库......据我所知,所有登录详细信息都是正确的但我收到此错误消息:用户'a5247024_thesps'@'10.1.1.36'访问被拒绝到数据库'maininf'

<?php
// Make a MySQL Connection
mysql_connect("mysql11.000webhost.com", "a5247024_thesps", "******") or     die(mysql_error());
mysql_select_db("maininf") or die(mysql_error());

// Retrieve all the data from the "maininf" table
$result = mysql_query("SELECT * FROM maininf")
or die(mysql_error());  

// store the record of the "maininf" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry 

echo "Name: ".$row['PUA_Name'];


?>

有人可以帮忙吗?非常感谢。

2 个答案:

答案 0 :(得分:5)

您显然可能会将表名与数据库名混淆。除非两者您的表和数据库都被称为maininf,否则您对mysql_select_db()的调用可能需要一个不同的字符串作为数据库的实际名称,而不是表名。 / p>

// Your database name may not be the same as your table name!
// Substitute the correct value in place of maininf here
mysql_select_db("maininf") or die(mysql_error());

// Retrieve all the data from the "maininf" table
$result = mysql_query("SELECT * FROM maininf")
or die(mysql_error());  

答案 1 :(得分:0)

我首先尝试使用这些凭据从bash访问MySQL。

然后,尝试添加端口号:

示例:

mysql11.000webhost.com:3306

还要检查用户是否具有对数据库“maininf”的访问权限。您可以使用MySQL的SHOW GRANTS来查看是否可以读取数据库。

相关问题