Database Reference
In-Depth Information
LEAVE
expire_loop
;
END
IF
;
CALL
exec_stmt
(
CONCAT
(
'ALTER USER '
,
account
,
' PASSWORD EXPIRE'
));
END
LOOP
;
CLOSE
cur
;
END
;
The procedure requires the
exec_stmt()
helper routine (see
Recipe 9.9
). Scripts to
create these routines are located in the
routines
directory of the
recipes
distribution.
23.6. Assigning Yourself a New Password
Problem
You want to change your password.
Solution
Use the
SET
PASSWORD
statement.
Discussion
To assign yourself a new password, use the
SET
PASSWORD
statement and the
PASS
WORD()
function:
SET
PASSWORD
=
PASSWORD
(
'
my
-
new
-
password
'
);
SET
PASSWORD
permits a
FOR
clause that enables you to specify which account gets the
new password:
SET
PASSWORD
FOR
'
user_name
'@'
host_name
' = PASSWORD('
my
-
new
-
password
'
);
This latter syntax is primarily for DBAs because it requires the
UPDATE
privilege for the
mysql
database.
If
SET
PASSWORD
complains about the password hash being in the wrong format, try
again after setting
old_passwords
to select the hashing method appropriate for the
authentication plug-in associated with your account.
Recipe 23.2
provides these values.
To check the strength of a password you're considering, use the
VALIDATE_PASS
WORD_STRENGTH()
function (see
Recipe 23.4
).
23.7. Resetting an Expired Password
Problem
You cannot use MySQL because your DBA expired your password.