To set special characters for password, use the following syntax -
create user 'yourUserName'@'yourHostName' identified by 'yourSpecialCharacterPassword';
Let us implement the above syntax to create a new user and set the password using special characters -
mysql> create user 'Mike'@'localhost' identified by 'Mike_123456'; Query OK, 0 rows affected (0.35 sec)
Let us check the table that stores MySQL users and hosts -
mysql> select user,host from MySQL.user;
This will produce the following output. New user created successfully -
+------------------+-----------+ | 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)
The above is the detailed content of Set special characters for password when creating new MySQL user?. For more information, please follow other related articles on the PHP Chinese website!