Skip to content

Instantly share code, notes, and snippets.

@harshit98
Forked from asquare14/ResetMysql.md
Created May 27, 2019 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harshit98/5109b2083d2134b20945f56cf82c3617 to your computer and use it in GitHub Desktop.
Save harshit98/5109b2083d2134b20945f56cf82c3617 to your computer and use it in GitHub Desktop.
Reset your MySQL password on MACOS
  • Stop the mysql service.

    $ brew services stop mysql

  • Kill all mysql processes

    $ pkill mysqld

  • This will delete ALL your existing database !

    $ rm -rf /usr/local/var/mysql/ # NOTE: this will delete your existing database!!!

  • Install mysql and restart the service.

    $ brew postinstall mysql

    $ brew services restart mysql

  • Go into the mysql commandline.

    $ mysql -uroot

  • Then change the mysql password .

    SET PASSWORD FOR root = 'mysql';

  • Then FLUSH PRIVILEGES; and exit;.

Here are some reference links for your help.

https://stackoverflow.com/questions/9695362/macosx-homebrew-mysql-root-password/18439812

https://stackoverflow.com/questions/50177216/how-to-grant-all-privileges-to-root-user-in-mysql-8-0?rq=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment