Setting and changing passwords

To change the password of a user or to set a password for a user that doesn't have one, we can use the GRANT statement, but that implies that we are adding permissions to a user. To change or set a password without changing any permissions; it's much easier to use the SET PASSWORD statement. It has the following pattern:

SET PASSWORD FOR <user> = PASSWORD('<password>');

The following is an example of this:

SET PASSWORD FOR 'henry'@'%' = PASSWORD('niftypassword');

Note

Complete documentation of the SET PASSWORD statement is available at the following location:

https://mariadb.com/kb/en/set-password/

Get Getting Started with MariaDB - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.