1. Start the service
DOS command
net start mysql 回车
2. Log in to the MySQL database
mysql -uroot -proot 回车
3. View the database in MySQL
show databases;
4. Create a database
create database 数据库名;
After the creation is completed, check whether the creation is successful again through the show databases; command
5. Delete the database
drop database 数据库名;
6, create a table
Note: Before operating data, "use database"
use database name;
create table
create table 表名(
字段1 数据类型(长度) ,
字段2 数据类型(长度) not null,
PRIMARY KEY(字段1)
);``
Reference case screenshot
7. Add a single record in the table
insert into table name (field 1, field 2, ...) values (value 1, value 2, ...);
Note that each value corresponds to the type of the field.
Reference case screenshot:
8. Query
select * from table name;
refer to the screenshot (continue to the previous step to see if data is added)
9. Add multiple records
insert into table name (field 1, field 2, ...) values (value A1, value A2, ...), (value B1, value B2, ...);
refer to the case screenshot
10. Delete
delete from table name;
refer to the case screenshot
11. Modify
update table name set field 1=value 1, field 2=value 2,...;
Note: each value and field type corresponds
to the screenshot of the reference case