mysql basic operations, start, log in, add, delete, modify, etc.

1. Start the service
DOS command

net start mysql Enter

2. Log in to the MySQL database
mysql -uroot -proot and press Enter

3. View the
show databases in MySQL ;

4. Create database
create database database name;

After the creation is completed, check whether the creation is successful again through the show databases; command

5. Delete the database
drop database database name;

6. Create table
Note: Before operating data, "use database"
use database name;
create table

create table table name (
field 1 data type (length),
field 2 data type (length) not null,
PRIMARY KEY (field 1)
); ``

7. Add a single record in the table
insert into table name (field 1, field 2, ...) values ​​(value 1, value 2, ...);

8. Query
select * from table name;

9. Add multiple records
insert into table name (field 1, field 2, ...) values ​​(value A1, value A2, ...), (value B1, value B2, ...);

10. Delete the
delete from table name;

11. Modify the
update table name set field 1=value 1, field 2=value 2,...;

Guess you like

Origin blog.csdn.net/lwguang0612/article/details/114238887