[MySQL Beginner Series 1]: Teach you how to get started with MySQL

If you are a novice who has just started to learn MySQL, this article will provide you with some practical introductory knowledge and skills to help you get started quickly.
This article will take windows as an example to introduce the basics of MySQL and how to install, uninstall, configure and use it.

1. Overview

1.1 What is MySQL

MySQL is an open source relational database management system (RDBMS), which uses SQL (Structured Query Language) to query and manage data. MySQL is widely used in the background data processing of web applications because it can process large amounts of data quickly, and has high reliability, good security, and easy use and management.
MySQL supports a variety of operating systems, including Windows, Linux, Unix, and Mac OSX. It also has extensive documentation and community support, making it one of the most popular and widely used databases in web development.

1.2 Why learn MySQL?

  • Learning MySQL can help us better understand and apply database technology, help us deal with a large amount of complex data, and improve data processing efficiency.
  • MySQL can run on a variety of platforms, and it is completely open source. Learning MySQL can help us learn SQL language, understand the process of data modeling and database management, and further improve our ability to apply and develop databases.

Two, MySQL download

Before we can start using MySQL, we need to install it first. The following are the MySQL installation steps:

It is recommended to download the latest version of the MySQL installation package from the MySQL official website: https://dev.mysql.com/downloads/mysql/ (or choose to use other MySQL client software, such as phpMyAdmin or Navicat, as long as it can be installed)
Download The page is shown in the figure below. There are free version (community version) and commercial version. We can download the community version.
download link:
insert image description here
insert image description here

3. MySQL installation

Double-click to execute the installation file, select the installation path of MySQL, and install it.
This is a fool-like installation process. Click next all the way to the following configuration window:

insert image description here

Note: There are 5 installation types listed in the figure, namely:

  • Developer Default: the default installation type;
  • Server only: only as a service;
  • Client only: only as a client;
  • Full: fully installed;
  • Custom: Custom installation type.

The installation program will install MySQL on the computer and prompt us to set the root user password :
In the last step of the installation, click the Next button to enter the server configuration window, confirm the configuration information, and click the Next button after confirmation, as shown in the figure.
insert image description here
Click the Next button

insert image description here
Click the Next button
insert image description here
to continue next
insert image description here
to
insert image description here
continue So far, the installation has been completed.

Note: Before you start using MySQL, don't get the mysql configuration wrong. The default port number of MySQL Server is 3306, we need to make sure that this port is not occupied. If it is occupied, we can use another available port by changing the configuration file.

Four, MySQL uninstall

If we no longer need to use MySQL, we can uninstall it through the following steps:

  1. Open the Programs and Features list in Control Panel.

  2. Select MySQL and click Uninstall.

  3. Select "Delete the data folder and all MySQL user data" in the pop-up prompt, and then click "Yes".

  4. After the uninstallation is complete, we can manually delete the MySQL installation directory and other related files and folders.

5. Basic knowledge of MySQL related concepts

After the installation is complete, we can start creating MySQL databases and tables.

For example: In MySQL, we use SQL statements to create, manipulate and manage databases and their contents. The following are some common MySQL SQL statement operations:

创建数据库:`CREATE DATABASE database_name;`
删除数据库:`DROP DATABASE database_name;`
创建表格:`CREATE TABLE table_name (column1 datatype, column2 datatype, column3 datatype, ...);`
删除表格:`DROP TABLE table_name;`
插入数据:`INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);`
查询数据:`SELECT * FROM table_name WHERE condition;`

5.1 Database startup and connection

The method of starting MySQL depends on the operating system. On Windows, we can use the SQL Server Configuration Manager to start or stop the MySQL service.
In Linux system, we can use command line or script to start or stop MySQL service.

We use the MySQL client to connect to the MySQL server, browse, query and manage the MySQL database.
There are multiple clients available for MySQL, including the MySQL command line client, MySQL Workbench, and Navicat, among others.

Use the MySQL command line client to connect to the MySQL database through the following commands:

mysql -u username -p -h hostname database_name

Among them, username is the username on the MySQL server, hostname is the name of the MySQL server, and database_name is the name of the database to be connected. After executing this command, you need to enter a username and password to connect to the database.

5.2 Database

In MySQL, a database refers to a collection of objects such as data, tables, and views. Users can access and manipulate data in the database through SQL statements. To create a new database, use the following SQL statement:

CREATE DATABASE database_name;

5.3 Data Sheet

A data table is a collection of related data in a database, and a table consists of some columns and zero to many rows. To create a new data table, you can use the following SQL statement:

CREATE TABLE table_name (column1 datatype, column2 datatype, column3 datatype, ...);

Among them, table_name is the name of the table you want to create, column1, column2, column3, etc. are the names of the columns you want to create in the table, and datatype is the data type of these columns, such as INT, VARCHAR, TEXT, etc.

5.4 SQL statement

SQL is the abbreviation of Structured Query Language, which is a language for managing relational databases. In MySQL, you can use various SQL statements to access and manipulate data in the database. The following are some commonly used SQL statements:

  • SELECT statement: used to select data from one or more data tables.
SELECT column1, column2, ... FROM table_name;
  • INSERT statement: used to insert new rows into the data table.
INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);
  • UPDATE statement: used to update existing rows in the data table.
UPDATE table_name SET column1=value1, column2=value2, ... WHERE condition;
  • DELETE statement: used to delete rows from the data table.
DELETE FROM table_name WHERE condition;

5.5 Data Types

MySQL supports a wide variety of data types, including numeric types, date and time types, string types, and more. The following are some commonly used data types:

  • INT: Used to store integer values.
  • VARCHAR: Used to store variable-length text strings.
  • DATE: Used to store date values.
  • TIME: Used to store time values.
  • DATETIME: Used to store both date and time values.

Guess you like

Origin blog.csdn.net/fumeidonga/article/details/131197806