Skip to content

Instantly share code, notes, and snippets.

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 kpssachin/0337daa7f7493717acf683f59d4c203b to your computer and use it in GitHub Desktop.
Save kpssachin/0337daa7f7493717acf683f59d4c203b to your computer and use it in GitHub Desktop.
Reset MySQL Root Password in Mac OS

Reset mysql root password in Mac OS:

First Stop MySQL:

  1. Go to: 'System Preferences' >> 'MySQL' and stop MySQL

OR,

  1. sudo /usr/local/mysql/support-files/mysql.server start
  2. sudo /usr/local/mysql/support-files/mysql.server stop
  3. sudo /usr/local/mysql/support-files/mysql.server status

Process to Reset MySQL Root Pass in Mac:

  1. Make sure you have Stopped MySQL first (above).
  2. Run the server in safe mode with privilege bypass:
    sudo mysqld_safe --skip-grant-tables
  3. In a new window connect to the database, rest the authentication for root user.
    For MySQL 8+ use:
    mysql -u root
    UPDATE mysql.user SET authentication_string=null WHERE User='root';
    FLUSH PRIVILEGES;
    exit;
  4. Set the new password for the root user.
    mysql -u root
    ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
  5. More info: http://stackoverflow.com/questions/6474775/setting-the-mysql-root-user-password-on-os-x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment