1#First Login with administrative account (Even root itself)
2
3mysql> use mysql;
4mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD("NewPassword");
5mysql> flush privileges;
6
7#Now quit and login
8mysql> quit
9
10mysql -u root -p
11#Click enter and It will prompt you to enter password
12#Just to be safe you should also still try to log in without entering a password
1$ sudo mysql -u root -p
2Enter password: (enter your root password)
3
4mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_new_password';
5mysql> FLUSH PRIVILEGES;
6mysql> exit;
7
8then to confirm
9
10mysql -u root -p
11Enter password: ********
12
13Success!!!
14
1use mysql;
2
3update user set authentication_string=PASSWORD("mynewpassword") where User='root';
4
5flush privileges;
6
7quit
8
1#Change or update mysql root password
2#Go to win cmd and cd into C:\Program Files\MySQL\MySQL Server 8.0\bin
3#Then type in the following: (password - current root password)
4mysqladmin -u root -p password newpass
11. If you in skip-grant-tables mode in mysqld_safe:
2
3mysql> UPDATE mysql.user SET authentication_string=null WHERE User='root';
4mysql> FLUSH PRIVILEGES;
5mysql> exit;
6
7and then, in terminal:
8
9$ mysql -u root
10
11in mysql:
12mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
13
14
152. Not in skip-grant-tables mode just in mysql:
16mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';