有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

将MySQL数据库移动到远程服务器后php“拒绝用户访问”

我在访问数据库时遇到了一些问题

这个脚本以前在我的本地主机上运行过。我把它导入了另一台服务器,而另一台服务器给了我一条拒绝访问的消息

给出的消息是:Access denied for user 'root'@'10.4.1.163' (using password: YES)

我使用的脚本是:

<?php
    // Connect to database server
    mysql_connect("localhost", "root", "password") or die (mysql_error ());

    // Select database
    mysql_select_db("database") or die(mysql_error());

    // SQL query
    $strSQL = "SELECT * FROM users WHERE user_id='". $_SESSION['USER_ID'] ."'";

    // Execute the query (the recordset $rs contains the result)
    $rs = mysql_query($strSQL);

    // Loop the recordset $rs
    // Each row will be made into an array ($row) using mysql_fetch_array
    while($row = mysql_fetch_array($rs)) {

       // Write the value of the column FirstName (which is now in the array $row)
      echo $row['Name'] . " ";
      }

    // Close the database connection
    mysql_close();
?>

我还尝试将localhost更改为IP地址10.4.1.163

我的剧本怎么了。我确信我使用的密码是正确的

有人知道我怎么解决这个问题吗


共 (0) 个答案