I will give an example of changing the root password for MySQL.
Connect to the MySQL server:
mysql -u root -p
Let’s see what users are (as there may be several root users with different hosts):
select * from mysql.user; select user,host from mysql.user;
Suppose there is only one “root’@’localhost”, then change the password to it:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
Done, the password is changed, now we’ll exit the MySQL console: