Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set root password to null

How can I change the password for root user of MySQL to null -- meaning no password or '' -- from the MySQL command line client?

like image 832
Stormshadow Avatar asked Jan 20 '10 13:01

Stormshadow


People also ask

How do I reset MySQL root password?

In the mysql client, tell the server to reload the grant tables so that account-management statements work: mysql> FLUSH PRIVILEGES; Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use.

What is default MySQL root password?

The default user for MySQL is root and by default it has no password. If you set a password for MySQL and you can't recall it, you can always reset it and choose another one.


2 Answers

Worked for me and "5.7.11 MySQL Community Server":

use mysql; update user set authentication_string=password(''), plugin='mysql_native_password' where user='root'; 

I had to change the 'plugin' field as well because it was set to 'auth_socket'.

After that I could connect as mysql -u root without a password.

like image 175
Stanislav Karakhanov Avatar answered Oct 07 '22 03:10

Stanislav Karakhanov


If you want an empty password, you should set the password to null and not use the Password hash function, as such:

On the command line:

sudo service mysql stop sudo mysqld_safe --skip-grant-tables --skip-networking & mysql -uroot 

In MySQL:

use mysql; update user set password=null where User='root'; flush privileges; quit; 
like image 41
user64141 Avatar answered Oct 07 '22 02:10

user64141