MySQL User Management: Add User, authorization, delete users

Add user

  Log in as root user database, run the following command:

  create user xixi identified by '123456';

   The above command creates a user xixi, password is 123456. In mysql.user table you can view the new user's information:

   select user,host,authentication_string from mysql.user where user='xixi';

  

Authorize

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

  grant all privileges on *.* to xixi@'%' identified by '123456';   flush privileges;

  The above statement will be all permissions for all database operations are licensed to the user xixi.

  

You can show grantssee the command to grant permission to execute the command:

show grants for 'xixi';

privilegesCode express grant of permission types commonly used are the following types [1]:

    • all privileges: All right.
    • select: read access.
    • delete: delete permissions.
    • update: Update permission.
    • create: Create permission.
    • drop: delete the database, data table permissions.

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

    • * : Grant the database server all database permissions.
    • dbName *:. dbName granted permission to the database all the tables.
    • dbName.dbTable: grant permissions in the database dbName dbTable table.

username@hostThe grant represents the IP address of the user and allows the user to log in. Host which has the following types:

    • localhost: only allow the user to log on locally, not remotely log on.
    • %: Allows any machine remotely log in addition to the machine.
    • 192.168.52.32: specific IP represents only allows the user to log in from a particular IP.

password specified surface when the user logs on.

flush privileges represent the refresh permission to change.

 

change Password

  Run the following command to change the user password

  update mysql.user set authentication_string = password('xixi') where user = 'xixi' and host = '%';   
  flush privileges;

delete users

  Run the following command to delete a user:

  drop user xixi@'%';

    drop user command to delete the user and the corresponding privileges, execute the command after you will find the corresponding record mysql.user mysql.db table and the table are gone.

 

Common command group

 Create a user specified database and grant full rights: For MySQL users to create Web applications

create user xixi identified by '123456'; grant all privileges on zhangsanDb.* to xixi@'%' identified by '123456'; flush privileges;

 Creating a user zhangsan, all permissions and database zhangsanDB grant zhangsan. If you want zhangsan can log in from this machine, it can be more given permission to localhost:

grant all privileges on *.* to xixi@'localhost' identified by '123456';

 

Starting at: https: //www.cnblogs.com/chanshuyi/p/mysql_user_mng.html

 

  Log in as root user database, run the following command:

  create user xixi identified by '123456';

   The above command creates a user xixi, password is 123456. In mysql.user table you can view the new user's information:

   select user,host,authentication_string from mysql.user where user='xixi';

  

Authorize

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

  grant all privileges on *.* to xixi@'%' identified by '123456';   flush privileges;

  The above statement will be all permissions for all database operations are licensed to the user xixi.

  

You can show grantssee the command to grant permission to execute the command:

show grants for 'xixi';

privilegesCode express grant of permission types commonly used are the following types [1]:

    • all privileges: All right.
    • select: read access.
    • delete: delete permissions.
    • update: Update permission.
    • create: Create permission.
    • drop: delete the database, data table permissions.

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

    • * : Grant the database server all database permissions.
    • dbName *:. dbName granted permission to the database all the tables.
    • dbName.dbTable: grant permissions in the database dbName dbTable table.

username@hostThe grant represents the IP address of the user and allows the user to log in. Host which has the following types:

    • localhost: only allow the user to log on locally, not remotely log on.
    • %: Allows any machine remotely log in addition to the machine.
    • 192.168.52.32: specific IP represents only allows the user to log in from a particular IP.

password specified surface when the user logs on.

flush privileges represent the refresh permission to change.

 

change Password

  Run the following command to change the user password

  update mysql.user set authentication_string = password('xixi') where user = 'xixi' and host = '%';   
  flush privileges;

delete users

  Run the following command to delete a user:

  drop user xixi@'%';

    drop user command to delete the user and the corresponding privileges, execute the command after you will find the corresponding record mysql.user mysql.db table and the table are gone.

 

Common command group

 Create a user specified database and grant full rights: For MySQL users to create Web applications

create user xixi identified by '123456'; grant all privileges on zhangsanDb.* to xixi@'%' identified by '123456'; flush privileges;

 Creating a user zhangsan, all permissions and database zhangsanDB grant zhangsan. If you want zhangsan can log in from this machine, it can be more given permission to localhost:

grant all privileges on *.* to xixi@'localhost' identified by '123456';

 

Starting at: https: //www.cnblogs.com/chanshuyi/p/mysql_user_mng.html

 

Guess you like

Origin www.cnblogs.com/yx88/p/11258083.html