gpt4 book ai didi

php - 用户 'www-data' 的访问被拒绝 @'localhost'

转载 作者:行者123 更新时间:2023-11-29 12:22:27 24 4
gpt4 key购买 nike

运行代码时出现此错误。如何将用户 www-data 更改为 root

//终端记录的错误

[Tue Mar 03 10:33:01.023877 2015] [:error] [pid 3161] [client 127.0.0.1:37725] PHP Warning:  mysql_query(): Access denied for user 'www-data'@'localhost' (using password: NO) in /var/www/html/wow/register.php on line 23, referer: http://localhost/wow/register.php

[Tue Mar 03 10:33:01.023957 2015] [:error] [pid 3161] [client 127.0.0.1:37725] PHP Warning: mysql_query(): A link to the server could not be established in /var/www/html/wow/register.php on line 23, referer: http://localhost/wow/register.php


// Codes inside register.php
<?php
require('config.php');

if(isset($_POST['submit'])){

//Perform the verification of the nation
$email = $_POST['email'];
$confirmEmail = $_POST['confirmEmail'];
$pass = $_POST['pass'];
$confirmPass = $_POST['confirmPass'];

if($email == $confirmEmail){
if($pass == $confirmPass){
//All good, Carry on.
$firstName = mysql_escape_string($_POST['firstName']);
$lastName = mysql_escape_string($_POST['lastName']);
$userName = mysql_escape_string($_POST['userName']);
$email = mysql_escape_string('email');
$confirmEmail = mysql_escape_string('confirmEmail');
$pass = mysql_escape_string('pass');
$confirmPass = mysql_escape_string('confirmPass');

mysql_query("INSERT INTO `users` (`id`, `firstName`, `lastName`, `userName`, `email`, `pass`) VALUES (NULL, '$firstName', '$lastName', '$userName', '$email', '$pass')") or die("Can't Connect!");


} else{
echo "Sorry, your passwords do not match. <br />";
}

} else {
echo "Sorry, your email's do not match. <br />";
}
} else{

$form = <<<EOT
<form action="register.php" method="POST">
First Name: <input type="text" name="firstName"/><br />
Last Name: <input type="text" name="lastName"/><br />
Username: <input type="text" name="userName"/><br />
Email: <input type="text" name="email"/><br />
Confirm Email: <input type="text" name="confirmEmail"/><br />
Password: <input type="password" name="pass"/><br />
Confirm Password: <input type="password" name="confirmPass"/><br />

<input type="submit" value="Register" name="submit"/>
</form>
EOT;

}

echo $form;

?>

最佳答案

第一个错误是当您尝试连接到数据库时。

config.php 上,您可能会看到类似 www-data 作为数据库用户,将其更改为正确的用户名和密码。

您还可以在项目中搜索单词 www-data

由于第一个错误,您遇到了第二个错误。由于您的连接失败,您的链接为 null

关于php - 用户 'www-data' 的访问被拒绝 @'localhost',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28823735/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com