Log in to MySQL
mysql-h192.168.56.1 -p33060-uroot-pEnter Password: * * * *
1. Add Users
Insert into MySQL. User (Host,uservalues('%''xiaoming'), Password ('xiaoming123'));
You can now log in to MySQL using your account (xiaoming,xiaoming123). But only the default permissions, only two databases can be manipulated, information_schema and test
2. Authorization
Grant < Permissions list > on < Relationships > to < users/roles >
Grant Insert on school. * to Xiaoming
At this point, the user xiaoming has the INSERT permission on the database school.
Mysql>show databases; Before---authorization +--------------------+| Database |+--------------------+|Information_schema||Test|+--------------------+2Rowsinch Set(0.00sec) MySQL>show databases; After---authorization +--------------------+| Database |+--------------------+|Information_schema||School||Test|+--------------------+3Rowsinch Set(0.00sec) MySQL> UseSchool;DatabaseChangedmysql> Insert intoStudent (Name,score)Values('xiaoming', -); Query OK,1Row affected (0.08sec) MySQL> Select * fromstudent; ERROR1142(42000):SELECTCommand denied to User 'xiaoming'@'10.0.2.2' for Table 'Student'
3. Adding users and authorizations
Grant < permissions > on < relationships > to ' < users > ' @ ' < host > ' identified by ' < password > '
MySQL>Grantselect on school. * to [Email protected] ' % ' by ' xiaoqiang123 ';
Add a new user and authorize
4. Create a role
MySQL database user, role, authorization