Access denied for user 'username'@'localhost' (using password: YES) in C:\\webdev\\wamp\\www\\membershipSite\\classes\\Mysql.php on line 9

笑着哭i 提交于 2019-12-03 15:19:54

You need to grant permissions to the user@host in mysql. The grant command looks like

grant all privileges on YOURDB.* to
'YOURUSER'@'localhost' identified by 'YOURPASSWORD';

Just a side answer as i came to this answer from my own problem but had a different solution as i knew all privileges were given to the user in question

I was using code such as

        <?php

        session_start();

        $db_host="host";
        $db_user="user";
        $db_pass="mypassword";
        $db_name="dbname";
        $db_table="tblname";

        mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
        mysql_select_db($db_name) or die(mysql_error());

The problem here was that the database password that i had used a generator for included a $ symbol which confused the script and thought there was another variable in starting in

        $db_pass="mypass$word";
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!