Database Reference
In-Depth Information
*D47F09D44BA0456F55A2F14DBD22C04821BCC07B
The result returned by the statement is the encrypted password. We'll copy that, log into
the server, and use it to change the password for admin_granter@localhost , like so:
SET PASSWORD FOR 'admin_granter' @ 'localhost' =
'*D47F09D44BA0456F55A2F14DBD22C04821BCC07B' ;
This will immediately update the privileges cache for the new password. Try that on your
server and then see whether you can log in with the P1ed_Avoce7-79873 password.
TIP
If you forget the root password, there's an easy way to reset it. First, create a simple text file with this
text, each SQL statement on one line:
UPDATE mysql . user SET Password = PASSWORD ( 'new_pwd' ) WHERE User = 'root' ;
FLUSH PRIVILEGES ;
Name this file something like rt-reset.sql and put it in a protected directory. Then start MySQL from the
command line using the --init-file option like so:
mysqld_safe -- init - file =/ root / rt - reset . sql &
Once it's started, log into MySQL to confirm the password has changed. You can change it again, if you
want. Then delete the rt-reset.sql file, and if you want, restart MySQL without the --init-file op-
tion.
Renaming a User Account
A username can bechanged with the RENAME USER statement.This SQL statement can
change the username and the host for the user account. The user account that you use to
rename another user account needs to havethe CREATE USER privilege, as well as the
UPDATE privilege for the mysql database.
In order to see how the RENAME USER statement works, let's rename the
lena_stankoska@lena_stankoska_home user account to lena@stankoskahouse.com , as-
suming she is the owner of that domain and will access our databases from it. Do that by
entering the following:
RENAME USER 'lena_stankoska' @ 'lena_stankoska_home'
TO 'lena' @ 'stankoskahouse.com' ;
Search WWH ::




Custom Search