MySQL's simplest specified database for authorization operations

Source: Internet
Author: User

Usage scenarios:

In daily use, the database system is often used, in which the Internet uses the most types of databases to be the MySQL database, but the use of this database is not only a single database for individual users (root), will be involved in rights management issues, To create a corresponding account for a database for individual authorization management, control the user can not ultra vires operation of other databases. Cannot have root privileges.

Solution:

1. Log in to the database using the root administrator account first.

#mysql-uroot-p

2. To see if the database is already available, take the bastion database as an example.

Mysql>show databases;+--------------------+| Database     |+--------------------+|Information_schema||Assets||Auth||Auto_test||Bastion||Different||Django||Hl7||Mysql||Performance_schema||phpMyAdmin||Scrap||Sys||System_openfalcon||Syswork|+--------------------+ -Rowsinch Set(0.02Sec

3, if the database is not created.

MySQL>Createdatabase bastion CharSet=UTF8

4. Create a user to manage the bastion database.

MySQL>CREATEUSER'bastion'@'localhost  'by' password ';


5, to the Bastion database authorization.

MySQL>Grant all on bastion. *  to ' Bastion '@'localhost';

6, login verification.

#mysql-Ubastion-penter password:welcome toThe MySQL Monitor. CommandsEnd  with;or\g.your MySQL Connection ID is 29298Server Version:5.7. A-0ubuntu0.16.04.1(Ubuntu) Copyright (c) -,2018, Oracleand/orits affiliates. Allrights reserved. Oracle isA registered trademark ofOracle Corporationand/oritsaffiliates. Names may trademarks oftheir respectiveowners. Type'Help ;' or '\h'  forHelp. Type'\c'  toClear the Currentinput statement. mysql>MySQL>show databases;+--------------------+| Database           |+--------------------+|Information_schema||Bastion|+--------------------+2Rowsinch Set(0.02sec) MySQL>MySQL>  UsebastionreadingTableInformation forCompletion of Table  and columnnamesyou can turnoffThis feature toGet a quicker startup with -ADatabaseChangedmysql>show tables;+----------------------------+|Tables_in_bastion|+----------------------------+|Acct||Auth_group||Auth_group_permissions||Auth_permission||Auth_User||Auth_user_groups||Auth_user_user_permissions||Django_admin_log||Django_content_type||Django_migrations||Django_session||Host||Host_grp||Manage_user|| Order                      ||Privilege|| User                       |+----------------------------+ -Rowsinch Set(0.01sec) MySQL>

The above can be used normally by the user for the exclusive use of the database operation.

MySQL's simplest specified database for authorization operations

Related Article

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.