[Java Advanced] MySQL startup and shutdown, directory structure and SQL related concepts

Insert image description here

MySQL service startup and shutdown

MySQL is a commonly used relational database management system. By starting and shutting down the MySQL service, you can control the running status of the database. This section will describe how to start and shut down the MySQL service on Windows and Linux systems.

Starting and shutting down the MySQL service on Windows

Start the MySQL service

On Windows, the MySQL service can be started by following these steps:

  1. Open Windows Service Manager. You can open the service manager by pressing Win + Rand then entering .services.msc

  2. In the service manager, find the MySQL service. Typically, the MySQL service name is MySQLor MySQL Server.

  3. Right-click the MySQL service and select Start.

Shut down the MySQL service

To shut down the MySQL service, perform the following steps in Service Manager:

  1. Open Windows Service Manager.

  2. Find the MySQL service, right-click it, and select Stop.

Start and shut down MySQL service on Linux

On Linux, the MySQL service can be started and shut down through terminal commands.

Start the MySQL service

To start the MySQL service on Linux, you can use the following command:

sudo service mysql start

Alternatively, if you are using systemd, you can use the following command:

sudo systemctl start mysql
Shut down the MySQL service

To shut down the MySQL service, you can use the following command:

sudo service mysql stop

Alternatively, if you are using systemd, you can use the following command:

sudo systemctl stop mysql

MySQL directory structure

The MySQL database system has a specific directory structure, which stores database data, configuration files, logs and other information. The following are some important directories of MySQL:

  • bin directory : Contains MySQL executable files, such as mysql, mysqldetc.

  • data directory : By default, MySQL data files are stored in this directory. Each database has a corresponding subdirectory that contains the data files for the tables.

  • etc directory : Contains MySQL configuration files, such as my.cnf.

  • var directory : used to store MySQL temporary files and log files.

  • lib directory : Contains MySQL library files.

  • share directory : Contains MySQL shared files, such as character set files and error message files.

  • scripts directory : Contains MySQL script files for database initialization and maintenance.

  • support-files directory : Contains some auxiliary tools and sample configuration files.

Please note that the directory structure of MySQL may vary depending on different operating systems and installation methods.

SQL related concepts

SQL (Structured Query Language) is a standardized query language used to manage relational databases. The following are some important concepts in SQL:

  • Database : A database is a container that contains objects such as tables, views, and stored procedures. Each database has a unique name for identification.

  • Data table (Table) : The data table is the main object in the database and is used to store data. A data table consists of rows and columns, with rows representing records and columns representing fields.

  • Field (Column) : A field is a column in a data table, used to store specific types of data.

  • Record (Row) : A record is a row in the data table and contains the actual data of the field.

  • Primary Key : A primary key is a column or a group of columns that uniquely identifies each record in a data table.

  • Foreign Key : A foreign key is one or more fields used to establish associations between data tables.

  • Query : Query is the process of using SQL statements to retrieve or manipulate data in a database.

  • INSERT statement : The INSERT statement is used to insert new records into the data table.

  • SELECT statement : The SELECT statement is used to retrieve data from a data table.

  • UPDATE statement : The UPDATE statement is used to update records in the data table.

  • DELETE statement : The DELETE statement is used to delete records in the data table.

  • Index : Index is a structure that optimizes database query performance and speeds up data retrieval operations.

  • Transaction : A transaction is a set of SQL operations that are treated as a single unit of work. Transactions either all succeed or all fail.

  • View : A view is a virtual table that is generated based on the query results of one or more actual data tables.

  • Stored Procedure : A stored procedure is a collection of SQL statements that can be saved and reused in the database.

  • Trigger : A trigger is a piece of SQL code that automatically executes when a specific event occurs in the database.

  • Normalization : Normalization is an important task in the database design process. It aims to eliminate data redundancy and improve data consistency.

  • Join : A join is an operation used to merge data from different data tables. It allows you to combine data together based on the value of the associated column.

  • Subquery : A subquery is a query nested within other queries, usually used to obtain data from the inner query for use by the outer query.

  • Aggregate Functions : Aggregate functions are functions used to calculate data summary values, such as SUM, AVG, COUNT, etc.

  • Transaction Isolation Level : Transaction isolation level defines the degree of isolation between multiple transactions, including read uncommitted, read committed, repeatable read and serialization levels.

These are some basic concepts in SQL and understanding them is very important to manage and operate the database effectively. In daily database operations, you will frequently use these concepts to perform a variety of tasks, from data query to data maintenance.

In the next blog, we will delve into various aspects of the SQL language, including detailed examples and usage of common operations such as query, update, insert, delete, etc. I hope this blog can help you build a solid SQL foundation.

Author information

Author: Fanyi
CSDN: https://techfanyi.blog.csdn.net
Nuggets: https://juejin.cn/user/4154386571867191

Guess you like

Origin blog.csdn.net/qq_21484461/article/details/133365038