MySQL Forgot password login
-- user=mysql--skip-grant-tables--skip-networking & -u root
Create DATABASE MySQL
Use MySQL to enter MySQL database
Show tables View all data sheets
MariaDB[MySQL]>show tables;+---------------------------+|Tables_in_mysql|+---------------------------+|Columns_priv||Db||Event||Slow_log||Student||Tables_priv||Time_zone||Time_zone_leap_second||Time_zone_name|| User |+---------------------------+ -Rowsinch Set(0.00Sec
Show databases view an executable library
Desc STUDENT1 View Table structure
Drop MySQL Delete database
Create DATABASE Student1 charset UTF8 creating databases
Show CREATE Database student1 view table
Drop CREATE DATABASE Student1 Delete Table
Create a table Student1
MariaDB[MySQL]> Create TableStudent1 ( -IdintAuto_increment, -NameChar( +) not NULL, -Ageint not NULL, -Register_date Date not NULL, - Primary Key(ID)); Query OK,0Rows Affected (0.02Sec
Add data
Insert into Values ("Zhangshan",3, "()--");
SELECT * from Student1 View list ·
SELECT * from Student1 limit 2; Check the top two data
SELECT * FROM Student1 limit 2 offset 2; Check the second two data of article 2nd
SELECT * from Student1 where id>3; view data with ID greater than 3
SELECT * from Student1 where register_date like "2016-04%"; Fuzzy query time
Update Student1 Set name = "Chenssss", age = where id = 4; Modify the name and age of ID 4
Delete from student1 where name = "Chenssss"; Remove the value of name
Select *from student1 ORDER by ID ASC; Ascending system default Ascending
Select *from student1 ORDER by id desc; descending
Select Name, COUNT (*) from STUDENT1 group by name; Group
Select Name, COUNT (*) as Stu_num from Student1 Group by name; Name of name changed
Select Name, sum (age) from Student1 group by name; sum of Ages by name
Select COALESCE (Name, "Total"), sum (ages) from the Student1 group by name with Rolup;
ALTER TABLE STUDENT1 add sex enum ("M", "F"); Insert field sex
ALTER TABLE student1 drop age; Delete Field age
ALTER TABLE student1 modify sex enum ("M", "F") not NULL; Data type cannot be null
ALTER TABLE STUDENT1 change sex gender char (+) NOT null default "X"; Modify field named Gender and data type char (32)
Create a table Study_record
CREATE TABLE' Study_record ' (' ID ')int( One) not NULL,` Day`int( One) not NULL, ' status 'Char( +) not NULL, ' stu_id 'int( One) not NULL,PRIMARY KEY(' id '),KEY' fk_class_key ' (' stu_id '),CONSTRAINT' Fk_student_key 'FOREIGN KEY(' stu_id ')REFERENCES' Student1 ' (' id '))
Show create table Study_record; View table creation Record
Create a table
Create B Table
SELECT * FROM A inner join B on a.a=b.b; or select a.*,b.* from A, where a.a=b.b;
SELECT * from A LEFT join B on a.a=b.b; differential set
SELECT * from a LEFT JOIN B on a.a=b.b Union SELECT * from a RIGHT join B on a.a=b.b;
Begin;
rollback; Roll back
Commit, cannot roll back after submission
Show index from Student1; View index
Create INDEX index_name on Student1 (name (32));
Python Full stack development mys