When you are connected to MySQL as a regular user, use the first syntax to change your own password. If you connected as an administrator, you can change the password for another user as follows:
SET PASSWORD FOR zak@localhost = PASSWORD('flibble');
In fact to change another user's password you must have the UPDATE privilege on the mysql.user table. The SET PASSWORD command is available in all versions of MySQL, but you can also modify passwords by changing values in the user table. The previous command is equivalent to the following UPDATE statement:
UPDATE user SET Password = PASSWORD('flibble') WHERE User = 'zak' AND Host = 'localhost';
Remember, you must issue a FLUSH PRIVILEGES command after making any changes to the user table. This is not required if you use the SET PASSWORD command.