MySQL database user, role, authorization

Source: Internet
Author: User

Log in to MySQL

mysql-h192.168.56.1  -p33060-uroot-pEnter Password: * * * *

1. Add Users

Insert  into MySQL. User (Host,uservalues('%''xiaoming'), Password ('xiaoming123'));

You can now log in to MySQL using your account (xiaoming,xiaoming123). But only the default permissions, only two databases can be manipulated, information_schema and test

2. Authorization

Grant < Permissions list > on < Relationships > to < users/roles >

Grant Insert  on school. *  to Xiaoming

At this point, the user xiaoming has the INSERT permission on the database school.

Mysql>show databases; Before---authorization +--------------------+| Database           |+--------------------+|Information_schema||Test|+--------------------+2Rowsinch Set(0.00sec) MySQL>show databases; After---authorization +--------------------+| Database           |+--------------------+|Information_schema||School||Test|+--------------------+3Rowsinch Set(0.00sec) MySQL>  UseSchool;DatabaseChangedmysql> Insert  intoStudent (Name,score)Values('xiaoming', -); Query OK,1Row affected (0.08sec) MySQL> Select *  fromstudent; ERROR1142(42000):SELECTCommand denied to User 'xiaoming'@'10.0.2.2'  for Table 'Student'

3. Adding users and authorizations

Grant < permissions > on < relationships > to ' < users > ' @ ' < host > ' identified by ' < password > '

MySQL>Grantselect on school. *  to [Email protected] ' % '  by ' xiaoqiang123 ';

Add a new user and authorize

4. Create a role

MySQL database user, role, authorization

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.