search
HomeDatabaseMysql TutorialMySQL Advanced Knowledge Architecture Introduction

mysql video tutorialThe column introduces the structure of MySQL advanced knowledge

MySQL Advanced Knowledge Architecture Introduction

Recommended (free): mysql video tutorial

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
  • mysql server optimization
  • 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
    • DownloadMySQL-Client and MySQL-Server
    • http://downloads.skysql.com/archives/mysql-5.5/MySQL-server-5.5 .16-1.rhel4.i386.rpm
    • http://downloads.skysql.com/archives/mysql-5.5/MySQL-client-5.5.16-1.rhel4.i386.rpm
    • http://downloads.skysql.com/archives/mysql-5.5/MySQL-devel-5.5.16-1.rhel4.i386.rpm
  • Check whether the current system Installed MySQL
    • Query command: rpm -qa|grep -i mysql
    • Delete command: rpm -e --nodeps RPM package full name
  • Install mysql server (Pay attention to the tips)

    MySQL Advanced Knowledge Architecture IntroductionMySQL Advanced Knowledge Architecture Introduction

    • Set password Tip

  • Install mysql client
  • View the mysql user and mysql group created during MySQL installation
    • # cat /etc /passwd | grep mysql
    • cat /etc/group | grep mysql
  • Starting and stopping the mysql service
    • View MySQL start and stop status: # ps -ef | grep mysql
    • Start and stop operations:
      • # /etc/init.d/mysql start
      • # /etc/init.d/mysql stop
      • or
      • #service mysql start
      • #service mysql stop
    • Set MySQL self-starting service
      • #chkconfig mysql on Set automatic startup
      • # chkconfig --list | grep mysql Check whether automatic startup is set up
    • Modify the configuration file location
      • 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
    • Modify character set and data storage path
      • View characters Set
        • show variables like 'character%';
        • show variables like '%char%';

        • MySQL Advanced Knowledge Architecture Introduction

MySQL Advanced Knowledge Architecture Introduction

  • #character set

    • The default is that both the client and the server use latin1, so the characters will be garbled.
    • Modify the character set and modify the previously copied configuration file. (Detailed follow-up code)
    • MySQL installation location
      • View the installation directory under linuxps -ef|grep mysql
##/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/binRelated command directorymysqladmin mysqldump and other commands/etc/init.d/mysqlStart and stop related scripts

MySQL Advanced Knowledge Architecture Introduction

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

3. Mysql configuration file

Main configuration file
  • Binary log log-bin
    • Master-slave replication

MySQL Advanced Knowledge Architecture Introduction

    ##Error log log-error
    • It is turned off by default, recording serious warnings and error messages, detailed information on each startup and shutdown, etc.
  • Query log log
    • It 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
    • Two systems
      • windows
        • #You can choose many libraries in the D:\devSoft\MySQLServer5.5\data directory
      • Linux:
        • Default path
        • #cd /var/lib/mysql/
        • Look at all the libraries in the current system Then go in
        • #ls -1F | grep ^d
    • ##frm file
    • : Store 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

Overall overview

Compared with other databases, MySQL is a little different. Its architecture can be applied and work well in a variety of 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.

    MySQL Advanced Knowledge Architecture Introduction

  • 1. Connection layer
  • The top layer is some clients and connection services, including local sock communication and large Most communication similar to tcp/ip is implemented 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.
      2. Service layer
    • The second layer architecture mainly completes most of the core service functions, such as SQL interface, and completes cached queries. , SQL analysis and optimization and execution of some built-in functions. 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.
    • 3. Engine layer
    • Storage engine layer, the storage engine is really responsible for the storage and extraction of data in MySQL. The server communicates with the server through API Communicate with the storage engine. Different storage engines have different functions, so we can choose according to our actual needs. We will introduce MyISAM and InnoDB later
    • 4. Storage layer
    • The data storage layer mainly stores data in a file system running on a raw device. above, and complete the interaction with the storage engine.
  • Query description
First of all, the query process of mysql is roughly:
  • mysql client Establish a connection with the mysql server through the protocol, send the query statement, first check the query cache, if it hits, return the result directly, otherwise perform statement parsing
    • There is a series of preprocessing, such as checking whether the statement is written correctly, and then the query Optimize (such as whether to use index scan, terminate early if it is an impossible condition), generate a query plan, then start the query engine, start executing the query, call the API from the underlying storage engine to obtain data, and finally return 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
  • View what storage engine the current MySQL provides
      • mysql> show engines;
      Look at your MySQL current default storage engine:
      • show variables like '%storage_engine% ';
  • Default storage engine
  • MyISAM and InnoDB

    MySQL Advanced Knowledge Architecture IntroductionMySQL Advanced Knowledge Architecture Introduction

    Comparison of the two engines

  • Which one should Alibaba and Taobao use?
    • Percona has improved the MySQL database server and is better in function and performance. MySQL has been significantly improved. 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 has improved performance and concurrency. To do a better job,
    • Most of Alibaba’s mysql databases actually use the prototype of percona and modify it
Path Explanation Remarks

The above is the detailed content of MySQL Advanced Knowledge Architecture Introduction. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:简书. If there is any infringement, please contact admin@php.cn delete
How to Grant Permissions to New MySQL UsersHow to Grant Permissions to New MySQL UsersMay 09, 2025 am 12:16 AM

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

How to Add Users in MySQL: A Step-by-Step GuideHow to Add Users in MySQL: A Step-by-Step GuideMay 09, 2025 am 12:14 AM

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

MySQL: Adding a new user with complex permissionsMySQL: Adding a new user with complex permissionsMay 09, 2025 am 12:09 AM

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

MySQL: String Data Types and CollationsMySQL: String Data Types and CollationsMay 09, 2025 am 12:08 AM

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

MySQL: What length should I use for VARCHARs?MySQL: What length should I use for VARCHARs?May 09, 2025 am 12:06 AM

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.

MySQL BLOB : are there any limits?MySQL BLOB : are there any limits?May 08, 2025 am 12:22 AM

MySQLBLOBshavelimits:TINYBLOB(255bytes),BLOB(65,535bytes),MEDIUMBLOB(16,777,215bytes),andLONGBLOB(4,294,967,295bytes).TouseBLOBseffectively:1)ConsiderperformanceimpactsandstorelargeBLOBsexternally;2)Managebackupsandreplicationcarefully;3)Usepathsinst

MySQL : What are the best tools to automate users creation?MySQL : What are the best tools to automate users creation?May 08, 2025 am 12:22 AM

The best tools and technologies for automating the creation of users in MySQL include: 1. MySQLWorkbench, suitable for small to medium-sized environments, easy to use but high resource consumption; 2. Ansible, suitable for multi-server environments, simple but steep learning curve; 3. Custom Python scripts, flexible but need to ensure script security; 4. Puppet and Chef, suitable for large-scale environments, complex but scalable. Scale, learning curve and integration needs should be considered when choosing.

MySQL: Can I search inside a blob?MySQL: Can I search inside a blob?May 08, 2025 am 12:20 AM

Yes,youcansearchinsideaBLOBinMySQLusingspecifictechniques.1)ConverttheBLOBtoaUTF-8stringwithCONVERTfunctionandsearchusingLIKE.2)ForcompressedBLOBs,useUNCOMPRESSbeforeconversion.3)Considerperformanceimpactsanddataencoding.4)Forcomplexdata,externalproc

See all articles

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

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software