Create and delete users in Mysql
1. Add a user (in two forms ):
A. mysql> grant all on *. * to yushan @ "%" identified by "123 ";
Mysql> flush privileges; (refresh the system permission table)
(The execution will be completed in mysql. insert a record to the user table. "all" indicates all permissions (including adding, deleting, modifying, and querying permissions ),*. * Indicates all databases. yushan indicates the username, 123 indicates the password, and % indicates all matched hosts. The preceding information can be specified, such as grant select and update on db. * to yushan @ localhost identified by '100 ";)
B. directly add a record to mysql. user
Mysql> insert into mysql. user (Host, User, Password) values ("localhost", "yusuhan", password ("123 "));
Mysql> flush privileges;
In this way, a user named: yushan password: 123 (the password is encrypted) is created. However, the user has no permission because only three fields are added, you can also add permissions through grant:
Mysql> grant all on *. * to yushan @ localhost identified by '2017 ";
Mysql> flush privileges; (refresh the system permission table)
After adding a user, if you want to remotely log on to MySQL, you must keep up with the Host Ip address as follows:
[Root @ localhost ~] # Mysql-u yushan-p-h 192.168.59.123
Enter password: (Enter the password)
2. delete a user:
Mysql> delete from mysql. user where user = 'yushan ';
Mysql> flush privileges; (refresh the system permission table)