Log Query rights management engine index

Storage Engine:
Definition: a database engine that is driving various programs, which is responsible for handling the core part of the database related work.
Similarly, operating instructions database application projects will deal with the role by the database engine to the database.
Select engine:
large-sized data sets tend to InnoDB engine, because it supports transaction processing and fault recovery.
The size of the database determines the length of recovery time, InnoDB transaction log can take advantage of
data recovery, it will be faster.
Engine Classification: (Innodb):
The default version contains more than 5.5
Support Services
does not support full-text indexing
indexes and data in the same file, the structure of the table is in .ibd .frm file


(MyIsam):
The default version 5.5 or below 5.3
do not support transaction
support full-text indexing
.frm table data table structure .MYD MYI table index.

index
action: accelerate query speed
Cons: 5.3 and delete the following modifications slows down, 5.5 speed is not particularly slow
Analogy: Xinghua dictionary catalog, the index can be understood as a special file, if not the file, find the order will be slow to find the front to back, anything looks for fast data according to specific data structures (binary)

index classification:
primary key index: speed up queries + can not be repeated + can not key is empty primary
unique index: speed up queries + can not be repeated unique (column name)
joint unique index: speed up queries + can not be repeated unique (column name 1, column names, 2)
general index: speed up queries index ( 'column name')
index creation:
primary key index:
first:
Create Table T1 (
ID int AUTO_INCREMENT primary key,
name VARCHAR (32) Not null default '',
index the ix_name ( 'name')
) Engine = Innodb charset = utf8;
second:
ALTER Change Table T1 ID AUTO_INCREMENT ID int Primary Key;
unique index:
first:
Create Table T1 (
ID int Primary Key AUTO_INCREMENT,
VARCHAR name (32) Not null default '',
UNIQUE the ix_name ( 'name')
) = Engine Innodb charset = UTF8;
second:
Create UNIQUE index Index Name (ix_name) on table (T1) (name);
Create UNIQUE index index name (ix_name_age) on table (t1) (name, age) ;
ordinary index:
first:
Create table T1 (
ID int Primary Key AUTO_INCREMENT,
name VARCHAR (32) Not null default '',
index the ix_name ( " name ")
) = Engine Innodb charset = utf8;
second:
the Create index (ix_naem) oN table name (t1) (name)
delete:
drop index name (ix_name) on the table name (t1);
usage scenarios: in accordance with demand frequent use of the indexed column;
Cons: version 5.3 plus index query speed will be very slow, very slow 5.6 is not

using the index: explain tool is to check the sql statement (efficiency) tool is the lingua franca of the index,
gives a report, to judge by the report sql the efficiency and effectiveness of
ES (elasticsearch)
rule: not recommended like conduct search query
leftmost prefix composite index
if the combination index (name, email)
where name and email using an index
where name using an index
email NA index where
slow log query ( show log):
log file: recording execution sql statement particularly slow
steps: Show varibles like '%% query'
sET = Global long_query_time. 1; set slow query time
show_query_log the ON =
show_query_log_file = E: \ MySQL-5.6.44- winx64 \ data \ oldboy-slow.log
ordinary log query (genneral):
sql audit: records sql operating statement
Step: Show varibles like '% genneral%';
the SET, Ltd. Free Join general_log = ON;
Rights Management :
Creating Permissions
create user 'username' @ 'ip address' identified by 'password'
EG: the Create the User 'wyf'@'192.168.1.123' IDENTIFIED by '123456'c
the Create the User' wyf'@'192.168.1.% 'IDENTIFIED by' 123456 '
the Create the User' wyf '@'% 'IDENTIFIED by' 123456 '
delete permissions
drop user 'username' @ 'ip address';
modify user
rename user 'username' @ 'ip address' to 'new user name' @ 'ip address'
to change the password
set password for 'username' @ 'ip address' = password ( "new password")
Authorization:
Grant permissions on the database tables to 'user' @ 'IP address'.
Grant the SELECT on db1 * to 'Zekai' @ '%';.
grant select on *.* to 'zekai'@'%';
grant select,insert,delete on *.* to 'zekai'@'%';
记住:
flush privileges;

Guess you like

Origin www.cnblogs.com/wyf20190411-/p/11040701.html