3. Add users:
(Note: Unlike the above, the following commands in the MySQL environment are followed by a semicolon as the command Terminator)
Format: grant select on database. * To username @ login host identified by "password"
First:
Add a user named "test1" with the password "ABC" so that he can log on to any host and have the permission to query, insert, modify, and delete all databases. First, use the root user to connect to MySQL, and then type the following command:
Grant select, insert, update, delete on *. * To test1 @ "%" identified by "ABC ";
However, the added users are very dangerous. If someone knows the password of test1, then, he can log on to your MySQL database on any computer on the Internet and do whatever he wants for your data. The solution is as follows:
First, add a user named "Test2" with the password "ABC" so that the user can only log on to localhost, you can also query, insert, modify, and delete the database mydb (localhost refers to the local host, that is, the host where the MySQL database is located), so that the user knows the password of Test2, he cannot directly renew data on the Internet either.
Mysql> grant select, insert, update, delete on book. * To Test2 @ localhost identified by "ABC ";
If you do not want Test2 to have a password, you can run another command to remove the password.
Mysql> grant select, insert, update, delete on book. * To Test2 @ localhost identified "";