0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

mysqlでAccess denied for user 'root'@'localhost' (using password: XXX)が出た時の対処法

Posted at

コマンド

  • mysqlのディレクトリがどこにあるか調べたい場合
which mysql

困った時😕

  • Access denied for user 'root'@'localhost' (using password: NO) エラーの対処法

※ update user set password = ‘’ where user=’root’はエラーになる。 mysql verup後にpasswordカラムが消えたらしい

## ① mysqlをstopさせる
mysql.server stop
mysql -u root

## ② passwordをリセットする
use mysql;
update user set authentication_string='' where user='root';

exit
  • Access denied for user 'root'@'localhost' (using password: YES) エラーの対処法

    • 原因

      • 単純にpasswordが間違っている
      • Dockerで起動させたDBとローカルで起動したDBのポートが競合してしまい、あっているはずのパスワードが間違っていると認識されてしまう
    • 解消策

      • 正しいPWを入力する
      • ポート3333でローカルから接続し、その後、Dockerで起動した3306ポートに『ポートフォワーディング』する
    #データベースコンテナ
    db:
    image: mysql:5.7
    ports:
    - '3333:3306'
    
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?