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