You might have had a situation where you forgot your MySQL root password. How will you solve such a problem in MacOS High Sierra. Here are some few steps to solving that issue that is resetting mysql root password.

Step 1: Stop MySQL service

You can do that by simply going to preference pane and click on MySQL then click on Stop MySQL Server or you type the command below in your Terminal to stop MySQL

sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop

Step 2: Skip Access Tables

For MySQL5 execute the command below in your Terminal

/usr/local/mysql/bin/mysqld_safe --skip-grant-tables

And for older versions of MySQL, execute the command below in your Terminal

/usr/local/mysql/bin/safe_mysqld --skip-grant-tables

Step 3: Reset MySQL root password

After running the above command in a Terminal, open another Terminal window and run the command below which will open up MySQL console making it easier for you to update your MySQL root user.

/usr/local/mysql/bin/mysql mysql

The query below will reset the root password

UPDATE user SET Password=PASSWORD(‘YOUR_PASSWORD’) WHERE Host=’localhost’ AND User=’root’;

If you are using MySQL5.7 the above code might not work for you. To make it work replace password  with authentication_string and you are good to go

UPDATE user SET authentication_string=‘YOUR_PASSWORD’ WHERE Host=’localhost’ AND User=’root’;

Replace “YOUR_PASSWORD” with your desired password.

Conclusion

Once you are done updating your root password use the exit;  command in the console to close the safe_mysqld execution.

Now, restart MySQL server using the following command

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

Once every step is successful then you can access MySQL again with no issues.

People reacted to this story.
Show comments Hide comments
Comments to: How to Reset MySql Root password on MacOS 10.13
  • […] View all posts How to Reset MySql Root password on MacOS 10.13 […]

    Reply
  • October 26, 2018

    Thanks for the marvelous posting! I definitely
    enjoyed reading it, you can be a great author. I will make sure to bookmark your blog and will come back at some point.

    I want to encourage you to definitely continue
    your great writing, have a nice afternoon!

    Reply
Write a response

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Login

Welcome to Typer

Brief and amiable onboarding is the first thing a new user sees in the theme.
Join Typer
Registration is closed.
%d bloggers like this: