Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 拒绝所有用户(包括root用户)访问MySQL_Php_Mysql_Mysqli - Fatal编程技术网

Php 拒绝所有用户(包括root用户)访问MySQL

Php 拒绝所有用户(包括root用户)访问MySQL,php,mysql,mysqli,Php,Mysql,Mysqli,我有一个PHP脚本,如下所示: $link = mysqli_connect("localhost", "gateway7_make", "$PASSWORD$"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { printf("Host information: %s\n", mysqli_get_host_in

我有一个PHP脚本,如下所示:

$link = mysqli_connect("localhost", "gateway7_make", "$PASSWORD$");
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
} else {
    printf("Host information: %s\n", mysqli_get_host_info($mysqli));
}
而且这个脚本始终输出

Connect failed: Access denied for user 'gateway7_make'@'localhost' (using password: NO)
除非我使用我的webhost密码,否则它会输出

Connect failed: Access denied for user 'gateway7_make'@'localhost' (using password: YES)
试图使用root@localhost给我和上面一样的信息

我知道用户名和密码是有效的,因为它们与安装在同一台机器上的phpmyadmin一起工作

脚本、mysql服务器和phpmyadmin都位于同一个Hostmonster服务器上


有人能告诉我我做错了什么吗?

错误是我的密码包含$,没有用正确的单引号括起来


感谢大家的帮助和时间。

尝试连接到计算机的ip地址,而不是本地主机。有时你需要添加单独的权限才能通过“localhost”连接到mysql。@JoeT,这只会给我一个错误连接失败:无法连接到“xx.xxx.xx.xxx”110@bobman321123上的mysql服务器,是的,我今天很笨:这有用吗?或者这是新代码吗?@Daniel,新代码,但是通过phpmyadmin连接是没有问题的?您知道PHP将尝试解析$PASSWORD并在结果中附加一个美元符号,因为所有这些表达式都用双引号括起来,对吗?