Mysql 拒绝用户访问';根'@';本地主机';访问DKAN时

Mysql 拒绝用户访问';根'@';本地主机';访问DKAN时,mysql,drupal,dkan,Mysql,Drupal,Dkan,我安装了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:

我安装了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)

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

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

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

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

其次,在its中配置Drupal应用程序以使用此新用户。

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

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

 CREATE USER drupal@localhost IDENTIFIED BY 'secretpassword';
 GRANT ALL ON drupaldatabase.* TO drupal@localhost;
其次,在its中配置Drupal应用程序以使用此新用户