[英]I keep getting this error when trying to open my website: SQLSTATE[28000] [1045] Access denied for user 'amaqhawe'@'localhost' (using password: NO)
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.
我最近在我的网站上添加了一个注册/登录系统,并且做了所有事情,包括在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.
现在的问题是,当我在浏览器中输入网站地址时,出现错误(SQLSTATE [28000] [1045]用户'amaqhawe'@'localhost'(使用密码:否)的访问被拒绝)。
My config.php file 我的config.php文件
<?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 PhpMyAdmin允许这样做
Or simple create new user ( look username and password at your configuration script ) 或简单地创建新用户(在配置脚本中查看用户名和密码)
Check your mysql user credentials. 检查您的mysql用户凭证。 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 检查您的phpmyadmin配置文件config.inc.php并更改此行
Location : If you are using Ubuntu/Debian 位置:如果您使用的是Ubuntu / Debian
/etc/phpmyadmin/config.inc.php
If Redhat/CentOs 如果是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) 由于您的密码是空的:默认情况下,phpmyadmin不允许空密码,这就是您得到的原因: 'amaqhawe'@'localhost'(使用密码: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
). 我创建了一个新用户,并将其添加到数据库(
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. 问题是我没有在用户凭据上写
amaqhawe_user
,我只写了user
,一开始就没有amaqhawe_
。 Thanks a lot for your inputs. 非常感谢您的投入。 You really helped me out big time.
你真的帮了我大忙。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.