Warning: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES)

前端 未结 21 2643
春和景丽
春和景丽 2020-11-22 06:31

Warning: mysqli_connect(): (HY000/1045): Access denied for user \'username\'@\'localhost\' (using password: YES) in C:\\Users\\xampp\\htdocs\\PHP_Login_Script

21条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 07:25

    Try the above answers 90% of the time this will be you issue. For me my problem was that my database password had a $ in it.

    $servername = '127.0.0.1';
    $username = 'user_bob';
    $password = 'sdfasdf$B';
    
    $conn = mysqli_connect($servername, $username, $password, 'any_database');
    
    //DO NOT USE DOUBLE QUOTES;
    //$password = "sdfasdf$B"; 
    

提交回复
热议问题