The default user for MySQL is root and by default it has no password.
user SET Password=PASSWORD('new password') WHERE User='root'; FLUSH PRIVILEGES; mysqladmin -u root -p shutdown Note: Once you shutdown mysqladmin, you would be seeing the safe mode exits in Terminal 1. sudo service mysql start That's it and it works like a charm with the new password!
as here says:
This function was removed in MySQL 8.0.11
1.if you in skip-grant-tables mode
in mysqld_safe:
UPDATE mysql.user SET authentication_string=null WHERE User='root';
FLUSH PRIVILEGES;
exit;
and then, in terminal:
mysql -u root
in mysql:
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
2.not in skip-grant-tables mode
just in mysql:
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
Jus login to mysql with sudo
Sudo mysql
Then
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
exit;
Test it
mysql -u root -p
Try this:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newPasswd';
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