https://dev.mysql.com/doc/refman/5.6/en/account-management-sql.html
USE mysql;
SELECT Host,User FROM user;
【BUG】
CREATE USER ‘xx‘@‘%‘ IDENTIFIED BY ‘yy‘;GRANT ALL PRIVILEGES ON *.* TO ‘xx‘@‘%‘ WITH GRANT OPTION;
#ERROR 1045 (28000): Access denied for user ‘xx‘@‘localhost‘ (using password: YES)
CREATE USER ‘xx‘@‘localhost‘ IDENTIFIED BY ‘yy‘;GRANT ALL PRIVILEGES ON *.* TO ‘xx‘@‘localhost‘ WITH GRANT OPTION;
DROP USER ‘xx‘@‘%‘;
DROP USER ‘ll‘@‘%‘;
【5.6 无效,在没重启服务的情况下;未测5.7、重启】
UPDATE user SET Password=‘newyy‘ WHERE User=‘xx‘;
#ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number
#SET PASSWORD FOR ‘xx‘@‘localhost‘ = ‘123‘;
【有效】
SET PASSWORD FOR ‘xx‘@‘localhost‘ = PASSWORD(‘123‘);
mysql> SELECT Host,User FROM user;
+-------------------+------+
| Host | User |
+-------------------+------+
| % | xx |
| 127.0.0.1 | root |
| ::1 | root |
| bigdata-server-02 | |
| bigdata-server-02 | root |
| localhost | |
| localhost | root |
| localhost | xx |
+-------------------+------+
8 rows in set (0.00 sec)
SET PASSWORD FOR ‘root‘@‘localhost‘ = PASSWORD(‘root123‘);
SET PASSWORD FOR ‘root‘@‘127.0.0.1‘ = PASSWORD(‘root123‘);
SET PASSWORD FOR ‘root‘@‘bigdata-server-02‘ = PASSWORD(‘root123‘);
SET PASSWORD FOR ‘root‘@‘::1‘ = PASSWORD(‘root123‘);