[2020.12.6]Mysql1

2020-12-06 10:23
Review the relevant notes compiled by mysql

Mysql

1. What is a database? What is a database management system? What is SQL? What is the relationship between them?

Database: English words, DataBase, DB for short, a combination of some files that store data in a certain format. That is, the warehouse for storing data is actually a bunch of files in which data in a specific format is stored.
Database management system: DatabaseManagementSystem, referred to as DBMS, the database management system is specialized in managing data in the database, and the database management system can add, delete, modify and check the data in the database. Common database management systems: MYSQL, Oracle, MS SqlServer, DB2, Sybase, etc...
SQL structured query language: The SQL statement that programmers need to learn, through specific writing of SQL statements, and then the DBMS is responsible for executing the SQL statements. Finally, the task of adding, deleting, modifying and checking database data is completed. SQL is a set of standards, and programmers mainly learn SQL statements. This SQL can be used in mysql, oracle, and db2.
The relationship between the three?
DBMS–Execute–>SQL–Operation–>DB
First install the database management system Mysql, and then learn how to write SQL. After writing the SQL statement, the DBMS executes the SQL statement, and finally completes the data management of the database.

2. Install Mysql database management system

Step 1: Install first, select "Classic Version";
Part 2: Mysql database instance configuration is required
Note: Just the next step all the way! ! !
Things to note:
Port number: port is available for any software/application, and the port number is the only representative of the application. The port number is usually together with the IP address. The IP address is used to define the computer, and the port number port is used to locate a certain service or application of the computer. On the same computer, the port cannot be repeated and is unique. The port number occupied by Mysql service is 3306 by default;
Character encoding method: Set the default character encoding method of mysql to UTF8. Note that first select the third radio button, and then select the UTF8 character set;
Service name: Mysql by default, no need to modify;
Select the configured environment variable path, if it is not configured, it can be manually configured later;
Mysql super administrator user cannot be changed, it must be: Root, while setting the password, you can check the Root user remote access, check it means that the Root account can be logged in outside the country, uncheck it means it can only be accessed on the local machine

3. Mysql perfect uninstall

Step 1: Double-click the installation package to uninstall
Step 2: Delete the directory: delete the MySQL directory under ProgramData under C drive
Step 3: Delete the directory: delete the MySQL directory under ProgramFiles (X86) under C drive

4. View computer MySQL service

Path: computer -> right click -> management-services and applications -> services -> find mysql service. The service is in the "started" state by default and "automatically started" by default, and it will start automatically the next time the system is started. You can right-click: start, restart, and stop the service; you can also change the default configuration of the service, select "automatic (delayed start)", "automatic", "manual", "disabled"

5. In Windows system, you can use commands to start and close the mysql service:

net stop service name;
net start service name;
Other services can also use this command

6. Mysql is installed and the service is started, how do I use mysql to log in to the database? Use the mysql.exe command in the bin directory to connect to the mysql database server

Insert picture description here
Insert picture description here

7. Mysql commonly used commands

Exit: exit
View the database: show databases; (to add a semicolon)
Choose to use a database: use + database name;
Create a database: create databases + database name;
View the version number of the mysql database: select version();

8. The most basic element in the database is the table (table)

Insert picture description here

Any table has rows and columns:
Row: called data/record;
Column: called a field;
To understand: each field has attributes such as field name, data type, and constraints;

9. SQL statement classification

DDL (Data Query Language): Any query statement with the select keyword;
DML (Data Manipulation Language): statements to add, delete, and modify data in the table, insert, update, and delete;
DDL (Data Definition Language): Any statement with create (create), drop (delete), alter (modify), the main operation is the structure of the table;
TCL (Transaction Control Language): Including transaction commit (commit), transaction rollback (rollback);
DCL (Data Control Language): Authorize grant, revoke authority revoke;

10. Simple query

10.1 Query a field

select field from table name;
Note: SQL statements are not case sensitive, all SQL statements end with ";"

10.2 Query multiple fields

select field 1, field 2 from table name;

10.3 Query all fields

select * from 表名;

10.4 List aliases

select field 1 (as) alias 1, field 2 () alias 2 from table name; (where as can be omitted, alias can be added "" or ", there can be spaces in between)
Note: In all databases, strings are enclosed in single quotation marks. Single quotation marks are standard. Double quotation marks cannot be used in oracle database, but they can be used in mysql
Again: the strings in the database are all enclosed in single quotes, double quotes are not standard

10.5 Columns participate in mathematical operations

Fields can participate in addition, subtraction, multiplication and division operations

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_45464945/article/details/110731705