LoginSignup
0
0

More than 1 year has passed since last update.

MySQLでパスワード忘れてとにかく入りたい時

Posted at

備忘録。

環境

macOS Monterey 12.2.1
MySQL Ver 8.0.30 for macos12.4 on x86_64 (Homebrew)

MySQLパスワード無しで入れるようにする

MySQLの設定ファイルmy.confを開く

$ sudo vi /etc/my.cnf

[mysqld]
skip-grant-tables
skip-networking

skip-grant-tablesで認証をOFFに、skip-networkingで外部(リモート)からの接続を禁止

$ mysql -u root 

で入る

パスワードを変更する

mysql> SET PASSWORD = "*****";

パスワードを変更するクエリ。

$ mysql -u root -p

でパスワードを聞かれれば成功

ごみ処理

さっき変更したmy.cnfを消すか、コメントアウトする。
私はもう一度いつかやりそうなのでコメントアウトしておく。

$ sudo vi /etc/my.cnf

[mysqld]
# skip-grant-tables
# skip-networking

参考文献

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