LoginSignup
2
1

More than 5 years have passed since last update.

Macにbrew installしたmysql Version5.7 rootパスワードを忘れた時の対処方法

Last updated at Posted at 2017-01-03

今日のお悩み

ずいぶん昔にインストールしたMySQLにパスワード設定したっぽいけど、忘れてアクセスできない

$ brew info mysql
mysql: stable 5.7.16 (bottled)

解決

> MySQLプロセス終了

sudo mysql.server stop

> mysqld_safeで起動

 $ /usr/local/bin/mysqld_safe --skip-grant-tables
2017-01-03T07:07:28.6NZ mysqld_safe Logging to '/usr/local/var/mysql/bohelabo.local.err'.
2017-01-03T07:07:28.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql

> rootパスワードの更新

update mysql.user set authentication_string=password("new_pass") where user='root';

> MySQLプロセス開始

sudo mysql.server start

>新しいパスワードで接続

mysql -u root -pnew_pass
2
1
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
2
1