mysql database to create users, empowerment, change password

Create a new user

create user lisi identified by '123456';

View create results:

 

Authorize

命令格式:grant privilegesCode on dbName.tableName to username@host identified by "password";

Command Description:

privilegesCode express grant of permission types, common are:

  1. all privileges: All rights;
  2. select: Read permission;
  3. delete: delete permissions;
  4. update: Update authority;
  5. create: Create permission;
  6. drop: delete the database, data table permissions.

dbName.tableName express permission granted to specific database or table, commonly used are:

  1. "* . *  " Dot represents the permissions granted to the user all databases and tables;
  2. dbName . *: dbName granted permission to the database all the tables;
  3. dbName.dbTable: grant permissions in the database dbName dbTable table.   

username @ host expressed in the host allowed to log IP, common are:

  1. localhost : only allow the user to log on locally, not remotely log in;
  2. %: Allow remote login;
  3. 192.168.12.34 : specific IP represents only allows the user to log in from a particular IP.

Create a new database dblisi: create database dblisi;

Empowering John Doe to use database dblisi: allow remote password is 123456

grant all privileges on dblisi.* to lisi@'%' identified by '123456';

Refresh permissions: flush privileges;

Log with account lisi: mysql -u lisi -p

Enter the password 123456

After landing successfully switched database:

 

Visible only have access to the database dblisi.

update mysql.user set password = password('12345678') where user = 'lisi' ;

Change password

Log in to directly modify the user's password:

 

 Although 0 rows affected, refresh failure, but make way 123 with a password to log in;

Remote can also be connected:

 

 

 Log root, change the password for the 123, refresh, as follows:

 

 Similarly 0 rows affected, but refreshing success;

Telnet has been a failure:

 

 

This is a strange phenomenon. It seems to change the root password using the set password is not OK. For a way:

update mysql.user set authentication_string=password('123') where user='root';
Refresh: flush privileges;

connection succeeded!

 

 

 Note, authentication_string is the password field under the new version of mysql.

 

delete users

drop user username@'%';

Guess you like

Origin www.cnblogs.com/wangyi0419/p/12070916.html