data的连接访问被拒绝

data的连接访问被拒绝

本文介绍了用户www-data的连接访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的PHP页面,该页面连接到数据库以读取值,当我将其本地部署时,这一切似乎都可以正常工作.但是,当我部署到服务器时,它将无法连接-在我看来,它正在忽略我的连接文件并使用默认值...?

I have a simple PHP page that connects to a database to read values and this all appears to work fine when I have it deployed locally. However when I deploy to my server then it wont connect - it looks to me like it is ignoring my connection file and using default values...?

    <?php
//Database details
include "Connection.php";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
?>

//Contents of Connection.php
<?php
  $user_name = "sam";
$password = "123456";
$database = "clubleague";
$server = "localhost";
?>

我回来的错误是:

我希望它说用户"sam"而不是www-data的访问被拒绝?在phpMyAdmin中,我有一个名为Sam的用户连接到数据库,我尝试为它授予对Global和本地数据库的完全权限,但没有任何乐趣.有任何提示,建议使它与我的凭据相关联吗?

I would have expected it to say Access denied for user "sam", not www-data?In phpMyAdmin I have a user called Sam attached to the database and I have tried giving it full permissions against Global and the local database but no joy. Any tips, suggestions to get it to connect with my credentials?

推荐答案

似乎未包含您的"Connection.php".为避免这种情况,请检查文件路径,然后使用"require"而不是"include"( http: //php.net/manual/en/function.require.php ).在这种情况下,"require"会向您抛出错误,并且您不会错过它们.

It looks like your "Connection.php" isn't included. For avoid this, check the path to file and use "require" instead "include" (http://php.net/manual/en/function.require.php). "require" throws you an error in this case and you don't missed them.

这篇关于用户www-data的连接访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 00:32