[Brew] Reset root password

2016/10/22 posted in  OSX

Check mysqld status by brew services and stop it.

  1. brew services ls
  2. brew services stop mysql

Chckc mysqld status by lsof and stop it.

  1. lsof -iTCP:3306
  2. mysql.server stop

Reset root password by mysqld_safe

  1. mysqld_safe --skip-grant-tables
  2. switch to new terminal
  3. mysql -u root
  4. mysql> FLUSH PRIVILEGES;
  5. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
  6. mysql> \q
  7. mysql.server start
  8. mysql.server stop
  9. brew services start mysql
  10. mysql -u root -p