Table of Contents
1. Introduction to MySQL
Overview
Advanced MySQL involves knowledge
3. Mysql configuration file
Main configuration file
5. Mysql storage engine
Home Database Mysql Tutorial An introduction to database architecture

An introduction to database architecture

May 05, 2017 pm 04:32 PM

1. Introduction to MySQL

Overview
  • MySQL is a relational database management system developed by the Swedish MySQL AB company and currently belongs to Oracle.

  • MySQL is a relational database management system that stores data in different tables instead of putting all data in one big warehouse, which increases speed and improves flexibility.

  • Mysql is open source, so you don’t need to pay extra.

  • Mysql supports large databases. Can handle large databases with tens of millions of records.

  • MySQL uses the standard SQL data language form.

  • Mysql can be used on multiple systems and supports multiple languages. These programming languages ​​include C, C++, Python, Java, Perl, PHP, Eiffel, Ruby and Tcl, etc.

  • Mysql has good support for PHP, which is currently the most popular web development language.

  • MySQL supports large databases and data warehouses with 50 million records. The 32-bit system table file can support a maximum of 4GB, and the 64-bit system supports a maximum table file of 8TB.

  • Mysql can be customized and adopts the GPL protocol. You can modify the source code to develop your own Mysql system.

Advanced MySQL involves knowledge
  • mysql kernel

  • sql optimization siege lion

  • Optimization of mysql server

  • Various parameter constant settings

  • Query statement optimization

  • Master-slave replication

  • Software and hardware upgrade

  • ##Disaster recovery backup

  • sql programming

  • Complete mysql optimization requires a deep foundation. Large companies even have dedicated DBAs to write the above

2. Installation of MySQL Linux version

  • This time I installed MySQL 5.5, and the installation environment is CentOS 6.5

  • version download Address official website download address

    • Download

      MySQL-Client andMySQL-Server

    • downloads.skysql.com/archives/mysql-5.5/MySQL-server-5.5.16-1.rhel4.i386.rpm

    • downloads.skysql.com/archives/mysql- 5.5/MySQL-client-5.5.16-1.rhel4.i386.rpm

    • downloads.skysql.com/archives/mysql-5.5/MySQL-devel-5.5.16-1 .rhel4.i386.rpm

  • Check whether MySQL is installed on the current system

    • ##Query command:
    • rpm -qa|grep -i mysql

    • Delete command:
    • rpm -e --nodeps RPM package full name

    Install mysql server (
  • Pay attention to the tips

    )

    • An introduction to database architecture
      Set password prompt

    Install mysql client
  • View the mysql user and mysql group created during MySQL installation
    • # cat /etc/passwd | grep mysql

    • cat /etc/group | grep mysql

    Start + stop mysql service
  • ##View character set
    • Modify the character set and modify the previously copied configuration file. (Detailed follow-up code)
    • MySQL installation location
    • ##show variables like 'character%';
    • show variables like '%char%';
    • ##Character set

      An introduction to database architecture

      The default is that both the client and the server use latin1, so the characters will be garbled.

    • View the installation directory under linux

      ps -ef|grep mysql

    • Copy the current 5.5 version

      :
    • cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
    • ##5.6 version

      cp /usr/share/mysql/my-default.cnf /etc/my.cnf
    • chkconfig mysql on Set automatic startup

    • # chkconfig --list | grep mysql Check whether automatic startup is set

    • # /etc/init .d/mysql start

    • # /etc/init.d/mysql stop

    • or

    • #service mysql start

    • service mysql stop

    • View MySQL start and stop status: # ps -ef | grep mysql

    • Start and stop operations:

    • Set up MySQL self-starting service
    • Modify the configuration file location
    • Modify the character set and data storage path
##/var/lib/mysql/Mysql database file storage path/var/lib/mysql/atguigu.cloud.pid/usr/share/mysqlConfiguration file directorymysql.server command and configuration file##/usr/bin/etc/init.d/mysql

An introduction to database architecture

MySQL installation location

[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock

# 这一行需要设置字符集
default-character-set=utf8

# The MySQL server
[mysqld]
port = 3306

# 还有这三行
character_set_server=utf8
character_set_client=utf8
collation-server=utf8_general_ci

socket = /var/lib/mysql/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

[mysql]
no-auto-rehash
# 还有这一行
default-character-set=utf8
Copy after login

3. Mysql configuration file

Main configuration file
  • Binary log log-bin

    • Master-slave replication

    • An introduction to database architecture


  • ##Error log log-error

    • The default is turned off, recording serious warnings and error messages, every Startup and shutdown details, etc.

  • Query log log

    • is turned off by default and records query sql statements. If it is turned on, it will reduce the overall performance of mysql. , because recording logs also consumes system resources

  • data files

    • windows

    • Linux:

    • #You can choose many libraries under the D:\devSoft\MySQLServer5.5\data directory

    • Default path

      #cd /var/lib/mysql/

    • Look at all the libraries in the current system and then go in

      #ls -1F | grep ^d

    • Two systems

    • frm file: Stores the table structure

    • ##myd file:

      Store table data

    • myi file:

      Store table index

    How to configure
    • Windows: my.ini file
    • Linux: /etc/my.cnf file
    4. Introduction to Mysql logical architecture

Overview

    Compared with other databases, MySQL is a little different. Architecture can be applied and work well in many different scenarios. Mainly reflected in the architecture of the storage engine,
  • the plug-in storage engine architecture separates query processing from other system tasks and data storage and extraction

    . This architecture allows the selection of appropriate storage engines based on business needs and actual needs.

    • The data storage layer mainly stores data on the file system running on the raw device and completes the interaction with the storage engine.
    • Storage engine layer, the storage engine is really responsible for the storage and retrieval of data in MySQL, and the server communicates with the storage engine through API. Different storage engines have different functions, so we can choose according to our actual needs. MyISAM and InnoDB will be introduced later
    • The second-layer architecture mainly completes most of the core service functions, such as SQL interfaces, and completes cached queries, SQL analysis and optimization, and some built-in functions. implement. All cross-storage engine functions are also implemented in this layer, such as procedures, functions, etc. At this layer, the server will parse the query and create the corresponding internal parse tree, and complete the corresponding optimization such as determining the order of the query table, whether to use indexes, etc., and finally generate the corresponding execution operation. If it is a select statement, the server will also query the internal cache. If the cache space is large enough, it can greatly improve system performance in an environment that handles a large number of read operations.
    • The top layer is some client and connection services, including local sock communication and most tcp/ip-like communication based on client/server tools. It mainly completes some connection processing, authorization authentication, and related security solutions. The concept of thread pool is introduced on this layer to provide threads for clients that securely access through authentication. SSL-based secure links can also be implemented on this layer. The server also verifies the operating permissions it has for each client that securely accesses it.
    • An introduction to database architecture


    • ##1. Connection layer
    • 2. Service layer
    • 3. Engine layer
    • 4. Storage layer
    • Query description
First, the query process of mysql Roughly:
  • The mysql client establishes a connection with the mysql server through the protocol, sends the query statement, and first checks the query cache. If there is a hit, the result is returned directly, otherwise the statement is parsed
    • There is a series of preprocessing, such as checking whether the statement is written correctly, and then query optimization (such as whether to use index scanning, if it is an impossible condition, terminate early), and generate queries Plan, then the query engine starts, starts executing the query, calls the API from the underlying storage engine to obtain the data, and finally returns it to the client. How to store data and how to retrieve data are all related to the storage engine.
    • Then, mysql uses the BTREE index by default, and a general direction is that no matter how you toss sql, at least for now, mysql only uses at most one index in the table.

5. Mysql storage engine

  • View command

    • show variables like '%storage_engine%';

    • mysql> show engines;

    • View What storage engine does the current MySQL provide?

    • Depends on the current default storage engine of your MySQL:

    • An introduction to database architecture

      Default storage engine

  • MyISAM and InnoDB

    • An introduction to database architecture

      Comparison of two engines

  • For Alibaba and Taobao Which

    • An introduction to database architecture


    • ##Percona for MySQL database server Improvements have significantly improved functionality and performance compared to MySQL. This version improves the performance of InnoDB under high load conditions, provides DBAs with some very useful performance diagnostic tools, and has more parameters and commands to control server behavior.

    • The company has created a new storage engine called

      xtradb which can completely replace innodb , and do better in performance and concurrency,

    • Most of Alibaba's mysql databases actually use the prototype of percona to be modified.

    【Related recommendations】

    1.

    Free mysql online video tutorial

    2.

    MySQL latest manual tutorial

    3.

    Boolean Education Yan Shiba mysql introductory video tutorial

Path Explanation Remarks
Related command directory mysqladmin mysqldump and other commands
Start and stop related scripts

The above is the detailed content of An introduction to database architecture. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the architecture and working principle of Spring Data JPA? What is the architecture and working principle of Spring Data JPA? Apr 17, 2024 pm 02:48 PM

SpringDataJPA is based on the JPA architecture and interacts with the database through mapping, ORM and transaction management. Its repository provides CRUD operations, and derived queries simplify database access. Additionally, it uses lazy loading to only retrieve data when necessary, thus improving performance.

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How does Hibernate implement polymorphic mapping? How does Hibernate implement polymorphic mapping? Apr 17, 2024 pm 12:09 PM

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

How steep is the learning curve of golang framework architecture? How steep is the learning curve of golang framework architecture? Jun 05, 2024 pm 06:59 PM

The learning curve of the Go framework architecture depends on familiarity with the Go language and back-end development and the complexity of the chosen framework: a good understanding of the basics of the Go language. It helps to have backend development experience. Frameworks that differ in complexity lead to differences in learning curves.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

Hand-tearing Llama3 layer 1: Implementing llama3 from scratch Hand-tearing Llama3 layer 1: Implementing llama3 from scratch Jun 01, 2024 pm 05:45 PM

1. Architecture of Llama3 In this series of articles, we implement llama3 from scratch. The overall architecture of Llama3: Picture the model parameters of Llama3: Let's take a look at the actual values ​​of these parameters in the Llama3 model. Picture [1] Context window (context-window) When instantiating the LlaMa class, the variable max_seq_len defines context-window. There are other parameters in the class, but this parameter is most directly related to the transformer model. The max_seq_len here is 8K. Picture [2] Vocabulary-size and AttentionL

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

Review! Comprehensively summarize the important role of basic models in promoting autonomous driving Review! Comprehensively summarize the important role of basic models in promoting autonomous driving Jun 11, 2024 pm 05:29 PM

Written above & the author’s personal understanding: Recently, with the development and breakthroughs of deep learning technology, large-scale foundation models (Foundation Models) have achieved significant results in the fields of natural language processing and computer vision. The application of basic models in autonomous driving also has great development prospects, which can improve the understanding and reasoning of scenarios. Through pre-training on rich language and visual data, the basic model can understand and interpret various elements in autonomous driving scenarios and perform reasoning, providing language and action commands for driving decision-making and planning. The base model can be data augmented with an understanding of the driving scenario to provide those rare feasible features in long-tail distributions that are unlikely to be encountered during routine driving and data collection.

See all articles