use mysql;
update user set authentication_string=password("your password") where user='root'; #(version without password field, that is, version <=5.7)
update user set password=password('your password') where user='root'; #(version with password field, version>5.7)
update user set plugin="mysql_native_password";
flush privileges;
exit;
Restart the service: service mysqld restart