Renaming a User


RENAME USER old_user@host TO new_user@host; 



You rename a MySQL user only very occasionally, but sometimes you need tofor instance, if your usernames are based on a user's real name and the person gets married. If Denise Black changes her surname to White, you would execute the following command to update her username:

RENAME USER dblack@localhost TO dwhite@locahost; 


The RENAME USER command has been available since MySQL 5.0.2. In earlier versions of MySQL, you have to update the user table by hand, along with any corresponding rows in db, remembering to use the FLUSH PRIVIGES command afterward:

UPDATE user SET User = 'dwhite' WHERE User = 'dblack' AND Host = 'localhost'; UPDATE db SET User = 'dwhite' WHERE User = 'dblack' AND Host = 'localhost'; FLUSH PRIVILEGES; 




MySQL Phrasebook. Essential Code and Commands
MySQL Phrasebook
ISBN: 0672328399
EAN: 2147483647
Year: 2003
Pages: 130

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net