MySQL——Basic operation and preliminary understanding of Dos window

I:

Operating system: Win11 system

mysql version: 8.0.34

Note: When the MySQL database is started, the default port number occupied is 3306

cmd commands are not case sensitive

cmd window (administrator) to start and shut down MySQL:

Start: net start MySQL80

shutdown: net stop mysql80

dos command window: mysql -uroot -p password (display password) mysql -uroot -p (hide password)

Exit mysql: exit

View the databases in the mysql database: show databases; (remember to bring English semicolons)

Use a database: use + database name; (remember to add a semicolon)

Create a database command: create database name;


1. MySQL------table

View those tables under the database: show tables;

Data is represented in the form of tables in the database (more intuitive).

Any table has rows and columns

Row: called record/data

Columns: called fields

Field: field name, data type, constraints and other attributes!

Unique constraint (unique): The data in this field cannot be repeated.

Two, the classification of SQL statements

DQL: Data Query Language (everything with the select keyword is a query statement)

select .......

View the data in the table: select * from table name

Look at the structure of the table, not the data in the table: desc table name

DML: data manipulation language (anything that adds, deletes, or modifies data in a table is DML), mainly operates the data in the table

insert: increase

delete: delete

update: change

DDL: Data definition language (everything with create, drop, alter, is DDL). DDL mainly operates on the structure in the table, not the data in the table.

create: Create a new one, which is equivalent to adding

drop: delete

alter: modify

This should be distinguished from DML, which modifies not the data in the table, but the structure of the table.

TCL: Transaction Control Language

commit: transaction commit

rollback: transaction rollback

DCL: Data Control Language

grant: authorization

revoke: revoke permission

Three, MySQL commonly used commands

Notice:

MySQL does not execute if there is no semicolon, and the semicolon means the end. So every command should end with a semicolon! ! !

When we make a mistake in a command, use \c to end this wrong command!

SQL statements are case insensitive!

1. View the version number of the MySQL database: select version()

2. Check which database is currently in use: select database(), note: this bjpowernode database is created by myself just now, not in mysql! ! !

3. Check the databases in the mysql database: show databases (the bjpowernode database is created by yourself, and the others are mysql databases)

4. Use a database: use + database name

5. Create a database command: create database file name

6. Check the tables under the database: show tables

7. View the data in the table: select * from table name

8. Look at the structure of the table, not the data in the table: desc table name

9. Exit mysql: exit

10. Import data: source data path

11. Delete the database: drop database database name

12. View the statement to create a table: show create table table name

Guess you like

Origin blog.csdn.net/m0_73968621/article/details/132467332