要设置密码的特殊字符,请使用以下语法 -
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)