In the MySQL environment, the system for user authentication and authorization management is flexible and powerful. It not only manages what operations can be performed, but also controls the hosts from which users can connect to the server. This increases security.
My machine is a Linux system. When I first set up MySQL, the user name is root and the password is set by myself. First, log on to MySQL:
$ Mysql-u root-p ******
Then you can create a user:
Format:
$ Grant perssions on databases. tables to 'username' @ 'permittedhost' identified by 'Password' with grant option;
For example:
$ Grant all on mysql. user to 'user' @ 'localhost' identified by 'www .bkjia.com ';
In this way, a user Local login user is created with the password www.bkjia.com, which has all permissions on the user table in the mysql database.
In addition, because the new user is essentially the user table in mysql, you can also insert a user record to create the user:
For example:
$ Insert into user values ('localhost', 'user _ name', password ('www .bkjia.com '));
The result is the same as the preceding one. However, you must run a statement after the statement is executed:
$ Flush privileges;
This statement is used to refresh the table related to system permissions so that the newly created user takes effect.