用户 'root'@'localhost' 访问被拒绝(使用密码:NO)?无法验证 php/Mysql? [英] Access denied for user 'root'@'localhost' (using password: NO)?Unable to authenticate php/Mysql?

查看:67
本文介绍了用户 'root'@'localhost' 访问被拒绝(使用密码:NO)?无法验证 php/Mysql?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误:

用户 'root'@'localhost' 的访问被拒绝(使用密码:NO)?"无法验证 php/Mysql

"Access denied for user 'root'@'localhost' (using password: NO)?" Unable to authenticate php/Mysql

我在 ubuntu 上使用灯服务器时遇到此错误.

I am getting this error using lamp server on ubuntu.

<?php
    $not_login = 0;
    if ($_SERVER["REQUEST_METHOD"] == "POST")
    {
        $servername = "localhost";
        $username = "root";
        $password = "";
        $con = mysql_connect($servername,$username);
        if ($con) {
            $db = mysql_select_db("ccmsdb",$con);
        }
        else{die(mysql_error());
    }
    $login = "LOGIN";

    $userid=$_POST['userid'];
    $password = $_POST['password'];
    //$password = md5($password);

    if ($db) {
        $query = "SELECT * FROM client WHERE   `userid`='$userid' AND `password`='$password' ";
        $result = mysql_query($query);
        $rows_count = mysql_num_rows($result);

        if ($rows_count>0) {

            header("Location:../welcome.php");
        }

        else
        {
            $not_login=1;
        }
        if(!empty($data))
        {

        }

    }
}
?>

<html>
       <form action=" " method="post">



        <h1>Log-In</h1>

      <p>   <label for="Userid">User Id:</label>

        <input type="text" name="userid">

    </p>

    <p>

        <label for="Password">Password:</label>

        <input type="Password" name="password">

    </p>
    <button>Login</button>

</form>

推荐答案

那个答案已经多次给出请参考以下链接.

That Answer Already Given Many Times Please refer Following Links.

用户root@localhost"的访问被拒绝(使用密码:NO)

'用户'root'@'localhost'的访问被拒绝(使用密码:NO)'

https://superuser.com/questions/603026/mysql-how-to-fix-access-denied-for-user-rootlocalhost

Php/Mysql 登录认证

如果无法解决问题,请转到此链接.

And If Can't Resolve the Issue then Go On This Link.

https://stackoverflow.com/help/duplicates

https://stackoverflow.com/help/how-to-ask

这篇关于用户 'root'@'localhost' 访问被拒绝(使用密码:NO)?无法验证 php/Mysql?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆