#1 Action folder (library)
Increase
Create Database db1 charset UTF8;
Check
show databases;
Show CREATE Database db1;
Change
ALTER DATABASE DB1 CharSet GBK;
By deleting
Drop database db1;
#2 Action file (table)
Switch to folder: Use DB1
Increase
CREATE TABLE T1 (id int,name char (TEN)) Engine=innodb;
CREATE TABLE t2 (ID int,name char (TEN)) Engine=innodb default CharSet UTF8;
Check
Show tables;
Show CREATE table T1;
desc T1; #查看表结构
Change
ALTER TABLE T1 add age int;
ALTER TABLE T1 modify name char (12);
By deleting
drop table T1;
#3 Line of contents of the action file (record)
Increase
INSERT into DB1.T1 values (1, ' Egon1 '), (2, ' Egon2 '), (3, ' Egon3 ');
Insert into DB1.T1 (name) VALUES (' Egon1 '), (' Egon2 '), (' Egon3 ');
Check
SELECT * from T1;
Select name from T1;
Select Name,id from T1;
Change
Update T1 set name= ' SB ' where id=4;
Update T1 set name= ' SB ' where name= ' Alex ';
By deleting
Delete from T1 where id=4;
#对于清空表记录有两种方式, but recommend the latter
Delete from T1;
Truncate T1; #当数据量比较大的情况下, using this method, the removal speed is fast
#自增id
CREATE TABLE t5 (ID int primary key auto_increment,name char (10));
CREATE table t4 (ID int not null unique,name char (10));
Insert into T5 (name) values
#创建用户
Create user ' lin ' @ ' localhost ' identified by ' 123 ';
#insert, Delele,update,select
#级别1: For all libraries, under all tables, under all fields
Grant SELECT On *. lin1 ' @ ' localhost ' identified by ' 123 ';
#级别2: All the fields under the DB1 library, under all tables,
Grant SELECT on db1.*-' lin2 ' @ ' localhost ' identified by ' 123 ';
#级别3: All fields below the table db1.t1
Grant SELECT on Db1.t1-' lin3 ' @ ' localhost ' identified by ' 123 ';
#级别4: Id,name field under Table Db1.t1
Grant Select (id,name) on db1.t1 to ' lin4 ' @ ' localhost ' identified by ' 123 ';
Grant Select (id,name), update (name) on db1.t1 to ' lin5 ' @ ' localhost ' identified by ' 123 ';
#修改完权限后, remember to refresh the permissions
Flush privileges;
mysql--additions and deletions to search