ERROR 1045(28000):ユーザー 'root' @ 'localhost'(パスワードを使用している場合はNO)のアクセスが拒否されました.

エラー1045(28000):ユーザー「root」@「localhost」のアクセスが拒否されました(パスワードを使用:NO)

MySQLサーバーへのログインを試みますが、次のエラーメッセージが表示されます。

ターミナル

$ mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

1. 解決策–(パスワードを使用:NO)

ユーザー「root」には、MySQLサーバーにログインするためのパスワードが必要です。 To solve it、MySQLサーバーへの接続中に-pフラグ付きのパスワードを入力してください。

$ mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 5.7.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

2. 解決策-(パスワードを使用:YES)

この(using password: YES)エラーが発生した場合:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

これは、無効なパスワードが提供されることを意味します。

Note
これを読んでくださいConnecting to the MySQL Server