MySQL Rights Management

Source: Internet
Author: User

#授权表user #该表放行的权限 for: All data, all tables under all libraries, and all the fields under the table db #该表放行的权限, for: a database, all tables under that database, and all the fields under the table Tables_priv #该表放行的权限. For: A table, and all fields under the table Columns_priv #该表放行的权限, for: A field # interpreted by the figure: User: Release db1,db2 and all of the db it contains: Release DB1, and all Tables_priv that DB1 contains: Release Db1.table1, and all columns_prive included in the table: Release Db1.table1.column1, release the field only

  

Example

#创建用户create user ' egon ' @ ' 1.1.1.1 ' identified by ' 123 ', create user ' Egon ' @ ' 192.168.1.% ' identified by ' 123 '; create user ' eg On ' @ '% ' identified by ' 123 '; #授权: to the folder, to the file, to the permissions of a field of a file to view Help: The most common permissions for helping Grant are: Select,update,alter, DeleteAll can represent all permissions except grant # for authorization for all libraries: *.*grant Select On *. * to ' egon1 ' @ ' localhost ' identified by ' 123 '; #只在user表中可以查到egon1用户的select权限被设置为Y # for a database: Db1.*grant select on db1.* to ' egon2 ' @ '% ' identified by ' 123 '; #只在db表中可以查到egon2用户的select权限被设置为Y # for a table: Db1.t1grant select on Db1.t1 to ' egon3 ' @ '% ' identified by ' 123 ';  #只在tables_priv表中可以查到egon3用户的select权限 # for a field: Grant Select (id,name), update (age) on Db1.t3 to ' egon4 ' @ ' localhost ' Identified by ' 123 '; #可以在tables_priv和columns_priv中看到相应的权限

  

Instance:

Create user ' egon1 ' @ '% ' identified by ' 123 ', grant SELECT On *. * to Egon1;select * from user  where user= ' Egon1 '; Grant s Elect on db1.* to Egon1;select * from DB where user= ' Egon1 '; grant all on db1.t1 to Egon1;select * from Tables_priv where u Ser= ' Egon1 '; Grant select (name), update (age) in Db1.t1 to Egon1;select * from Columns_priv where user= ' egon1 ';

  

MySQL Rights Management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.