App overview screenshotSQL and Database Guides
PostgresMySQLSQLite
Try our free SQL Client
Tools
Connecting to MySQL
Connecting to Drivers
Installing MySQL
Setting up MySQL
MySQL   >   
Setting up MySQL   >   
Reset MySQL 8 Password on MacOS

Reset the Password for MySQL 8 on Mac

How to reset MySQL 8 password on Mac

Mysql is a powerful database management system that is open-source and free. In order to prevent unauthorized access, it offers administrative access to the database system. You may also select which database operations a user is permitted to do.

In this post, we'll walk you through two basic steps for resetting your MySQL passwordon aMac`.

Prerequisites

In order to complete this tutorial, the following are required:

  • Having access to a server running MySQL e.g apache
  • You must have MySQL database already

Resetting MySQL password

In this post, we'll walk you through two basic steps for resetting your MySQL password on a Mac.

  1. Stoping a MySQL server

If mysql is being utilized, it must first be stopped from running. To do so, open your terminal and type the following command:

sudo /usr/local/mysql/support-files/mysql.server stop

This will bring the server to a stop, allowing us to proceed with the password reset.

  1. Running safe mode

We need to run MySQL server in safe mode with privilege bypass. To accomplish this, use the following command in the terminal:

sudo mysqld_safe --skip-grant-tables
  1. Setting the password

Now that we've bypassed MySQL server privilege, we need to reset the user password to null. To do so, start a new terminal and type the commands below:

mysql -u root
UPDATE mysql.user SET authentication_string=null WHERE User='root';

We can now modify the user password because it has been changed to null. To accomplish this, enter the following commands:

mysql -u root
UPDATE mysql.user SET authentication_string=PASSWORD("newpassword") WHERE User='root';
FLUSH PRIVILEGES;

Change the **newpassword **in the above command to your desired password.

recap

The overall command to change the password is as follows:

sudo /usr/local/mysql/support-files/mysql.server stop
sudo mysqld_safe --skip-grant-tables
mysql -u root
UPDATE mysql.user SET authentication_string=null WHERE User='root';
mysql -u root
UPDATE mysql.user SET authentication_string=PASSWORD("newpassword") WHERE User='root';
FLUSH PRIVILEGES;

Connecting with the new MySQL Password

Now that your password is reset, follow this guide to connect a SQL client to MySQL and start writing queries!

You can also run MySQL in Docker and connect to it in other languages like Java.

Conclusion

We learned how to change mysql 8 user password on Mac, as well as how to connect mysql with Arctype workspace in this article.

Get help on databases and SQL. Join our Discord community.