php - Access denied for user 'root'@'localhost' (using password: NO); -
i'm using php amd mysql(xampp). i'm trying connect php file database pdo. shows following error. (mysql_query(): access denied user 'root'@'localhost' (using password: no)). problem don't know. i'm using pdo first time. please tell me problem , solution. here code.
$dsn = 'mysql:dbname=abc;host=localhost'; $dbuser = 'user'; $dbpass = 'pass'; $params = array(pdo::attr_errmode => pdo::errmode_exception, pdo::attr_default_fetch_mode => pdo::fetch_assoc); $pdo = new pdo($dsn, $dbuser, $dbpass, $params);
$dsn = 'mysql:host=localhost;dbname=test'; $dbuser = 'user'; $dbpass = 'pass'; $params = array(pdo::attr_errmode => pdo::errmode_exception, pdo::attr_default_fetch_mode => pdo::fetch_assoc); $pdo = new pdo($dsn, $dbuser, $dbpass, $params);
you r doing mistake here mysql:dbname=abc;host=localhost
^^^^^^^^^^
Comments
Post a Comment