Understanding and Changing Passwords
This section explains how user passwords work in MySQL and how they can be set,
changed, and removed. Passwords can be of any length, though practical
limitations in some operating systems necessitate that they be no
longer than eight characters. When assigning passwords, we recommend that you follow the same
principles that you would with any other password-protected system:
choose passwords that have a mix of uppercase, lowercase, numeric, and
special characters; avoid using dictionary words; and avoid recording
your password anywhere it can be easily found. We use no passwords and
simple passwords—such as
—in
this chapter to demonstrate concepts, but we recommend that in
practice you use a more complex password that incorporates a mix of
letters, numbers, and punctuation symbols (for example, the_password
1n1T?s313Y0
). Of
course, choose a password that you can remember without having to
write it down somewhere; pieces of paper often turn up in the wrong
hands!
The simplest method to set a password is to use the IDENTIFIED BY
clause when you create or modify
the privileges of a user. You’ve seen several examples of this so far
in this chapter. Here’s one reproduced from a previous section:
mysql>
GRANT ALL ON music.* TO 'allmusic'@'localhost' IDENTIFIED BY '
the_password
';
Query OK, 0 rows affected (0.06 sec)
This process takes the
plain-text string
,
hashes it using the MySQL the_password
PASSWORD()
function, and stores the hashed string in the ...
Get Learning MySQL 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.