Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

[MySQL Learning Notes] 1. Installation and basic use

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The last winter vacation, immediately officially entered the industry, there are a lot of things to learn.

First of all, I intend to make up the knowledge of the database.

This note was written in Windows.

I. basic concepts

1. Data Data

2. Database Database

3. Database server Database Server

There are two types of users of the database:

Database engineer (DBA)

Developer

Several common databases:

About MySQL:

1. Cpact S mode:

The client and the server exchange data through a network connection

2 、 Linux/Windows

MySQL has distributions on both Linux and Windows, and is usually deployed on Linux

II. Installation

1. Download MySQL on the official website and install it

2. Configure and modify the following items in the configuration file my.ini:

Change the character set to gbk to support Chinese encoding (default is Latin character set)

Add a row, set to case-sensitive

3. Restart the MySQL service

4. Configure the firewall, or turn off the firewall directly

5. Configure the environment variable and add the XX/MySQL/bin path to the PATH environment variable

6. Testing, using mysqladmin under cmd, or using SQLyog (a client software)

Third, the login of database

Execute the following command under cmd

(note that each statement should end with a semicolon.)

But a simpler way is to use the client tools mentioned earlier to operate in a visual environment, and I will use SQLyog for the rest.

Create databases and tables

Data refers to tabular data. Row Row, column Column

Rows: each row is called a record (Record)

Columns: each column is called a field (Field)

Add and delete tables:

Multiple tables can be stored in a DataBase, and there can be multiple columns in a table. There are four main data types for each column:

1. Integers: tinyint, smallint, mediumint, int, bigint

2. Decimal: float, double

3. String: char, varchar

4. Long text: text

5. Time: data, time, datetime, timestamp

6. Binary data: blob

Wait.

Edit the format of the table:

When you create a new table, set its properties for each column (type, index, self-increment, default value), collectively referred to as schema (outline)

Edit the contents of the table:

Add a piece of data and save it

Add, delete, change: in the visual environment of SQLyog, it is easy to achieve these.

Fifth, the design of the table-- attributes, primary keys and indexes of columns (fields)

Each column (field) has the following properties:

1. Column name

It is suggested to name it in English. The naming rules can refer to the two styles of C++.

Do not use SQL keywords (such as int, text, type) as column names

2. Data type

1. Integers: tinyint (1 byte), smallint (2 byte), mediumint (3 byte), int (4 byte)

Long (8 byte)

2. Decimal: float, double

3. String: char, varchar

4. Long text: text

5. Time: date, time, datetime, timestamp

6. Binary data: blob (bulk data)

3. Length: when the data type is a string, you need to specify the length

4. Primary key: used to uniquely identify a record. Once a field is set as the primary key, the content of the field cannot be repeated for the data added later.

(extension-federated primary key: sometimes, multiple fields can be combined to form the primary key of a table. It is generally believed that this is not recommended, but a separate ID should be set up for each record.)

5. Non-empty: whether null is allowed

6. Self-increment: the value of the set column automatically increases with the current maximum value as data is added (only in cases not specified at initialization)

8. Unsigned: whether it is an unsigned number

9. Notes:

10. Index: used to speed up sorting and lookup (it takes more time to increase data and takes up more space, but it is more convenient to find)

The index is divided into ordinary index and unique index, and the fields of unique index are not allowed to be repeated.

The primary key is actually a unique index.

Full-text indexing: accelerated retrieval of large text

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report