Menu

Setting MySQL root password to nothing

Goal

Set mysql’s root password to null

Description

When I’m working on a local machine, I usually use mysql’s root password as nothing. Recently, I changed to a different laptop which had the root password setted (and I didn’t know which one was it, by the way!). This recipe explains how we can make the password be set to null

How to

This recipe consists on the following steps, according to this post in stackoverflow, which I put in my blog for future reference. All credits go to the author in the referenced site.

If we want an empty password, then we cannot use the Password hash function. Therefore, first, on the command line, we have to:

Explanations

This mechanism makes it possible to start MySQL without security checks, which allows us to log in with root user without password. Adter that, we change the root password to null, we flush privileges and we are ready to go. From that point on, everytime MySQL starts, root will have no password.