I'm failing to figure out what I did wrong. I've recently added a register/login system on my website and I did everything, including setting up the server info in PHPMYADMIN. Now the problem is that I get an error(SQLSTATE[28000] [1045] Access denied for user 'amaqhawe'@'localhost' (using password: NO)) when I type in my website address on a browser.
My config.php file
<?php
ob_start();
session_start();
//set timezone
date_default_timezone_set('South Africa');
//database credentials
define('DBHOST','localhost');
define('DBUSER','amaqhawe');
define('DBPASS','');
define('DBNAME','amaqhawe');
//application address
define('DIR','http://amaqhawe.co.za/');
define('SITEEMAIL','noreply@amaqhawe.co.za');
try {
//create PDO connection
$db = new PDO("mysql:host=".DBHOST.";dbname=".DBNAME, DBUSER, DBPASS);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
//show error
echo '<p class="bg-danger">'.$e->getMessage().'</p>';
exit;
}
//include the user class, pass in the database connection
include('classes/user.php');
include('classes/phpmailer/mail.php');
$user = new User($db);
?>
Check, that user defined at your scripts created and have permissions to using database ( on copying database you transfer data, not users and permissions)
PhpMyAdmin allow do this
Or simple create new user ( look username and password at your configuration script )
Check your mysql user credentials. They seem to be incorrect. I guess you need to specify your database password
Check you phpmyadmin config files config.inc.php and change this line
Location : If you are using Ubuntu/Debian
/etc/phpmyadmin/config.inc.php
If Redhat/CentOs
/etc/phpMyAdmin/config.inc.php
As your password is empty : By default phpmyadmin won't allow empty passwords that is why you are getting: 'amaqhawe'@'localhost' (using password: NO)
So modify the config file
$cfg['Servers'][$i]['AllowNoPassword'] = TRUE; // Change this form false to true
This will allow empty passwords now.
This may helps you.
The website is up and running now. I created a new user and added it to database ( amaqhawe_amaqhawe
). After that my database credentials looked like this:
//database credentials
define('DBHOST','localhost');
define('DBUSER','amaqhawe_admin');
define('DBPASS','960721');
define('DBNAME','amaqhawe_amaqhawe');
The problem is that I did not write amaqhawe_user
on my user credentials, I only wrote user
without including the amaqhawe_
in the beginning. Thanks a lot for your inputs. You really helped me out big time.
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.