I tried connecting to my database in WAMP, it first gave me SQLSTATE[HY000] [1045] Access denied for user 'C:/wamp/www'@'localhost' (using password: NO).
I later changed the password but still getting SQLSTATE[HY000] [1045] Access denied for user 'C:/wamp/www'@'localhost' (using password: YES)
.
In phpmyadmin, I added my password to it but nothing change. here is the code for config.inc:
<?php
/* Servers configuration */
$i = 0;
$cfg['blowfish_secret'] = 'h]C+{nqW$omNoTIkCwC$%z-LTcy%p6_j$|$Wv[mwngi~|e'; //What you want
/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'Local Databases';
$cfg['Servers'][$i]['host'] = 'localhost';//127.0.0.1
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'father2242';
// Hidden databases in PhpMyAdmin left panel
//$cfg['Servers'][$i]['hide_db'] = '(information_schema|mysql|performance_schema|sys)';
// Allow connection without password
$cfg['Servers'][$i]['AllowNoPassword'] = true;
// Suppress Warning about pmadb tables
$cfg['PmaNoRelation_DisableWarning'] = true;
// To have PRIMARY & INDEX in table structure export
//$cfg['Export']['sql_drop_table'] = true;
//$cfg['Export']['sql_if_not_exists'] = true;
$cfg['MySQLManualBase'] = 'http://dev.mysql.com/doc/refman/5.7/en/';
/* End of servers configuration */
?>
For my database connection parameters (db.ini):
;MySQLi hostname
host = localhost
;MySQLi Username
user = root
;MySQLi Password
pass = father2242
;MySQLi Table - Database
name = ddrive
Script for accessing the connection(database.php)
<?php
function DB() {
$dbconfig = (object) parse_ini_file(__DIR__.'/../ini/db.ini');
try {
$db = new PDO(
"mysql:host={$dbconfig->host};dbname={$dbconfig->name}",
$dbconfig->user,
$dbconfig->pass
);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $db;
} catch (PDOException $e) {
die($e->getMessage());
}
}
?>
Why am I getting this error? I am open to suggestions or criticisms.
Error 'C:/wamp/www'@'localhost' tells that user you try to connect with is 'C:/wamp/www', not 'root'. Could you check what is actually inside $dbconfig by printing it out?
Changing password in phpmyadmin config doesn't actually change password from database itself. Phpmyadmin is just a client, not database.
To change password from database you should change it in 'users' table in 'mysql' database using any client (like phpmyadmin):
Remove username and password from phpmyadmin config - it will allow you to login using web-form.
Open phpmyadmin and use default user/password pair. Most likely it is 'root' without password by default.
Go to users table, search for 'root' user with 'localhost' host and change password to PASSWORD('father2242')
Save row
Restart MySQL service
Everything should work after that - you will have root user allowed to access from localhost with password you chose.
Not sure why you have amended the config.inc.php
file, there is no need.
If you change these 2 lines back to there original state
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'father2242';
which was
$cfg['Servers'][$i]['user'] = '';
$cfg['Servers'][$i]['password'] = '';
When you run phpMyAdmin you should be presented with the phpMyAdmin
login page.
NOTE: The root
userid does not have a password set by default, like most MySQL installs.
So use Username = root
and leave the password blank
and this will log you in as the root
account.
If you did actually set a password on the root account, then you can use that password in the login page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.