【问题标题】:Access denied for user 'root'@'localhost' when accessing DKAN访问 DKAN 时用户 'root'@'localhost' 的访问被拒绝
【发布时间】:2020-11-30 22:51:15
【问题描述】:

我安装了 DKAN,并进行了短暂的工作。然后我关闭了所有内容并尝试再次打开它,我收到以下错误消息:

The website encountered an unexpected error. Please try again later.
Drupal\Core\Database\DatabaseAccessDeniedException: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) in Drupal\Core\Database\Driver\mysql\Connection::open() (line 156 of /var/www/html/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php).
Drupal\Core\Database\Driver\mysql\Connection::open(Array) (Line: 376)
Drupal\Core\Database\Database::openConnection('default', 'default') (Line: 166)
Drupal\Core\Database\Database::getConnection('default')
call_user_func_array('Drupal\Core\Database\Database::getConnection', Array) (Line: 79)
Drupal\Component\DependencyInjection\PhpArrayContainer->createService(Array, 'database') (Line: 171)
Drupal\Component\DependencyInjection\Container->get('database', 1) (Line: 260)
Drupal\Component\DependencyInjection\PhpArrayContainer->resolveServicesAndParameters(Array) (Line: 62)
Drupal\Component\DependencyInjection\PhpArrayContainer->createService(Array, 'cache.container') (Line: 171)
Drupal\Component\DependencyInjection\Container->get('cache.container') (Line: 513)
Drupal\Core\DrupalKernel->getCachedContainerDefinition() (Line: 868)
Drupal\Core\DrupalKernel->initializeContainer() (Line: 466)
Drupal\Core\DrupalKernel->boot() (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

我相信这可能是因为我输入了 usernameadmin 但是当我在笔记本电脑上创建它时(我使用 Ubuntu 18),数据库是从 root 创建的。但是,我仍然不知道这是否真的是问题或我该如何解决它

【问题讨论】:

    标签: mysql drupal dkan


    【解决方案1】:

    首先为您的 Drupal 实例创建一个新的数据库用户,而不是使用 root

    通过在命令行上运行mysql -u root -p 并输入密码。那么:

     CREATE USER drupal@localhost IDENTIFIED BY 'secretpassword';
     GRANT ALL ON drupaldatabase.* TO drupal@localhost;
    

    其次,在其configuration file 中配置 Drupal 应用程序以使用这个新用户。

    【讨论】:

      猜你喜欢
      • 2013-07-28
      • 2023-03-20
      • 2017-10-04
      • 2019-04-30
      • 2013-08-22
      • 2015-07-04
      • 2017-03-14
      相关资源
      最近更新 更多