Default MySQL username and password: the ultimate guide

  • by

Almost every MySQL user did ask the question „how to find MySQL default root password“ at least once.
The answer is easy for those, who did not change the default password during the installation process. In MySQL default admin user is root. There is also no password set for MySQL root user, by default.

How do I reset root password in MySQL

If you did changed the MySQL default root password and don‘t remember it, there is an easy way to reset it and create a new root password. Just follow the next X simple steps to reset MySQL root password

  1. Stop MySQL server using command line, if it is not already stopped

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

  1. Then start MySQL server with skip-grant-tables and skip-networking options. The first option allows you to connect to MySQL server without a password but with all privileges, and disables account-management statements such as ALTER USER and SET PASSWORD. The second is preventing the remote connections because running the server with skip-grant-tables privileges is very insecure.

sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking

  1. Connect to MySQL server. No password is necessary, because the server was started with skip-grant-tables option:

mysql -u root

  1. To reload the grant tables run the following sql command:


  1. Now you can set root mysql password using alter command:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password';

This is almost it. Now you should stop the MySQL server again and restart it in a normal way. Just run the last two commands in command line:

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

and you can connect to the MySQL Server with the new admin password.

Download dbHarbor for free to try SQL queries from this tutorial. ⚓️  dbHarbor is a native macOS tool with intuitive UI to manage SQL databases.

dbHarbor: SQLite

Don’t miss the latest news about our development journey and SQL tutorials. Signup for our newsletter. Promise not to SPAM😎


Leave a Reply

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