mysql> SELECT host, user, password FROM user WHERE user = 'guest'; +-----------+---------+------------------+ | host | user | password | +-----------+---------+------------------+ | localhost | guest | 6f8c114b58f2ce9e | +-----------+---------+------------------+ 1 row in set (0.00 sec) 当要添加一个新用户,记得要PASSWORD()函数加密MySQL新使用密码。正如在上面的例子中看到密码为mypass,进行加密后为:6f8c114b58f2ce9e.
D:/software/mysql-5.6.25-winx64/bin> mysql -u root -p password; Enter password: mysql> use mysql; Database changed
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP -> ON TUTORIALS.* -> TO 'zara'@'localhost' -> IDENTIFIED BY 'zara123'; 这也将创建一条记录在MySQL数据库中的表: user.