在创建新的 MySQL 用户时设置密码的特殊字符?
若要设置密码的特殊字符,请使用以下语法 −
create user 'yourUserName'@'yourHostName' identified by 'yourSpecialCharacterPassword';
让我们实现以上语法来创建新用户并设置带有特殊字符的密码 −
mysql> create user 'Mike'@'localhost' identified by 'Mike_123456'; Query OK, 0 rows affected (0.35 sec)
让我们查看 MySQL 用户和主机存储的表 −
mysql> select user,host from MySQL.user;
这将生成以下输出。新用户已成功创建 −
+------------------+-----------+ | user | host | +------------------+-----------+ | Bob | % | | Charlie | % | | Robert | % | | User2 | % | | mysql.infoschema | % | | mysql.session | % | | mysql.sys | % | | root | % | | @UserName@ | localhost | | Adam Smith | localhost | | Chris | localhost | | David | localhost | | James | localhost | | John | localhost | | John Doe | localhost | | Mike | localhost | | User1 | localhost | | am | localhost | | hbstudent | localhost | | mysql.infoschema | localhost | | mysql.session | localhost | +------------------+-----------+ 21 rows in set (0.00 sec)
广告