mysql adds and removes users and permissions assignments


1. New users

mysql>insert into mysql.user(Host,User,Password) values("localhost","lionbule",password("hello1234"));
mysql>flush privileges;

2. Change the user password

mysql>update mysql.user set password=password('new password') where User="lionbule" and Host="localhost";
mysql>flush privileges;

3. Delete users

mysql>DELETE FROM user WHERE User="lionbule" and Host="localhost";
mysql>flush privileges;

4. Assignment of authority

4.1. grant usage grant permissions on database.* to username @’ login host ‘identified by’ password ’

 Jurisdiction:
     Commonly used to summarize , ALL/ALTER/CREATE/DROP/SELECT/UPDATE/DELETE
 Database:
     *.*                     All tables representing all libraries
     test.*                 said test All the tables in the library
     test.test_table   said test The library test_table table     
 User name:
     mysql Account name
 Login host:
      Allowed to login mysql server The client ip
     '%' All said ip
     'localhost'  Says the native
     '192.168.10.2'  specific IP
 Password:
       The login password for the account

4.2 example

mysql>grant all  on test.* to lionbule@'%' identified by 'hello1234';
mysql>flush privileges;

User lionbule with a new password of ‘hello234’ has all permissions on the test library and does not restrict the access of lionbule users to IP.

4.3 Matters needing Attention

grant will cover part of the user’s information, just like insert and update.

Reference: http://dev.mysql.com/doc/refman/5.6/en/grant.html