How can I change the password for root
user of MySQL to null
-- meaning no password or ''
-- from the MySQL command line client?
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.
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.
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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With