简体   繁体   English

尝试打开我的网站时,我不断收到此错误:SQLSTATE [28000] [1045]用户'amaqhawe'@'localhost'的访问被拒绝(使用密码:NO)

[英]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. 这可能对您有帮助。

  1. Try to connect to database with the default user. 尝试使用默认用户连接到数据库。 (user: root with no password). (用户:root,没有密码)。 If you can, probably the problem is with your user. 如果可以,可能是用户遇到了问题。
  2. Check your user surely has no password set. 确定您的用户没有设置密码。
  3. Check whether that user has access to the database you are trying to use. 检查该用户是否有权访问您要使用的数据库。

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.

相关问题 SQLSTATE [28000] [1045]用户&#39;root&#39;@&#39;localhost&#39;的访问被拒绝(使用密码:NO) - SQLSTATE[28000][1045] Access denied for user 'root'@'localhost'(using password:NO) FOSUserBundle-SQLSTATE [28000] [1045]用户&#39;root&#39;@&#39;localhost&#39;的访问被拒绝(使用密码:NO) - FOSUserBundle - SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) Laravel 8: SQLSTATE[28000] [1045] 拒绝用户访问(使用密码:YES) - Laravel 8: SQLSTATE[28000] [1045] Access denied for user (using password: YES) 驱动程序中发生异常:SQLSTATE [28000] [1045]用户&#39;c1ser ****&#39;@&#39;localhost&#39;的访问被拒绝(使用密码:是) - An exception occured in driver: SQLSTATE[28000] [1045] Access denied for user 'c1ser****'@'localhost' (using password: YES) SQLSTATE [28000] [1045]用户&#39;root&#39;@&#39;localhost&#39;的访问被拒绝(使用密码:NO)生产中的Laravel - SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) Laravel in production Zend Framework- SQLSTATE [28000] [1045]用户&#39;webadmin&#39;@&#39;localhost&#39;的访问被拒绝(使用密码:是) - Zend Framework- SQLSTATE[28000] [1045] Access denied for user 'webadmin'@'localhost' (using password: YES) SQLSTATE [28000] [1045]用户&#39;root&#39;@&#39;localhost&#39;的访问被拒绝(使用密码:是) - SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES) 我在 ubuntu 上使用命令 sudo mysql 收到 ERROR 1045 (28000): Access denied for user &#39;root&#39;@&#39;localhost&#39;(使用密码:NO) - I got ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) with the command sudo mysql on ubuntu PDOException SQLSTATE [28000] [1045]拒绝访问用户&#39;homestead&#39;@&#39;localhost&#39; - PDOException SQLSTATE[28000] [1045] Access denied for user 'homestead'@'localhost' 输入密码:mysqldump:出现错误:1045:尝试连接时用户'XXX'@'localhost'的访问被拒绝(使用密码:NO) - Enter password: mysqldump: Got error: 1045: Access denied for user 'XXX'@'localhost' (using password: NO) when trying to connect
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM