使用 RENAME USER 語句時應(yīng)該注意以下幾點: RENAME USER 語句用于對原有的 MySQL 賬戶進(jìn)行重命名。 若系統(tǒng)中舊賬戶不存在或者新賬戶已存在,則該語句執(zhí)行時會出現(xiàn)錯誤。 要使用 RENAME USER 語句,必須擁有 MySQL 中的 MySQL 數(shù)據(jù)庫的 UPDATE 權(quán)限或全局 CREATE USER 權(quán)限。
使用 RENAME USER 語句將用戶名 james 修改為 jack,主機(jī)是 localhost。輸入的 SQL 語句和執(zhí)行過程如下所示。
mysql> RENAME USER james@'localhost' -> TO jack@'localhost'; Query OK, 0 rows affected (0.03 sec) 在 Windows 命令行工具中,使用 jack 和密碼 tiger 登錄數(shù)據(jù)庫服務(wù)器,如下所示。
C:/Users/USER>mysql -h localhost -u jack -p Enter password: ***** Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 7 Server version: 5.7.20-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '/h' for help. Type '/c' to clear the current input statement. 可以使用 SET PASSWORD 語句修改一個用戶的登錄密碼。
【test_user_new2】是新密碼
set password=password('test_user_new2'); mysql如何修改用戶