How MySQL new users (permissions), change your password, delete users

All users to view MYSQL database
MySQL> use MySQL;
MySQL> SELECT Host, User from User;
or
mysql> SELECT DISTINCT CONCAT ( 'User :' '', user, '' '@' '', host, '' '; ') AS query FROM mysql.user;
view the database permissions for a specific user
mysql> show grants for root @ localhost ;

1, administrator login as root MySQL
MySQL-uroot--p123456; -h192.168.1.1 -ua1 -p123456 or MySQL;
2, create a new user
create user a1 @ localhost identified by ' 123456'; # create only the local landing users
create user a1 @% identified by ' 123456'; # can be created outside the network login user
'%' - in all cases be able to access
'localhost' - the machine to access
111.222.33.44 - designated ip to access
NOTE: Change password
update mysql.user set password = password ( 'new password') where user = 'user1' ;
this access time, in addition to the two databases are generated by default, do not see any other database:
3, adding permissions to a user
with update command:
MySQL> MySQL use;
MySQL> Update User SET Host = '%' WHERE User = 'a1'; # a1 to add any ip all permissions

Or with the grant command:
grant all on want to authorize database. To a1 @ '%'; # to any ip all the permissions
database grant all on want to authorize.
To a1 @ localhost; # to localhost All rights
grant all on want to authorize database to a1 @ localhost identified by '123456 '; # create user authorization and at the same time note: the above command with an authorized user is not authorized to other users, if you want the user may be authorized to use the following command:
Grant ON want to authorize database .
to a1 @ localhost with the Option Grant;
Grant select ON want to authorize database * to a1 @ localhost identified by ' 123456';. # authority to select
4, delete users
delete from mysql.user where user = 'a1 ';
IV. refresh
flush privileges;
share:

Guess you like

Origin blog.51cto.com/hzcto/2415604