To install MySQL on CentOS system, you can choose to use the source code installation method. Compared with directly using binary package installation, this method can customize the configuration of MySQL more flexibly, and at the same time, it can also provide an in-depth understanding of the working principle of MySQL from the source code level.
This article will introduce the detailed steps to install MySQL using source code on CentOS system.
Step One: Preparation
Before you start installing MySQL, you need to install some necessary software packages and dependencies. You can use the following command to install:
yum groupinstall "Development Tools" yum install cmake ncurses-devel
Step 2: Download the source code
Download the source code package on the MySQL official website, select the version suitable for your server system and the corresponding compressed package:
https://dev.mysql.com/downloads/mysql/
Copy the downloaded source code package to the server where MySQL needs to be installed.
Step 3: Unzip the source code package
Use the following command to decompress the source code package:
tar -zxvf mysql-xxx.tar.gz
Step 4: Create MySQL users and groups
Create one Dedicate users and groups to running MySQL, which improves security. Use the following command to create:
groupadd mysql useradd -r -g mysql -s /bin/false mysql
Step 5: Compile and install MySQL
- Enter the MySQL source code directory
cd mysql-xxx
- Create a directory with To compile MySQL
mkdir bld cd bld
- Run the cmake command to configure the compilation parameters. You can modify the following parameters according to actual needs:
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_UNIX_ADDR=/var/run/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1
Parameter description:
-
-DCMAKE_INSTALL_PREFIX
: Specify the installation path of MySQL, the default is /usr/local/mysql. -
-DMYSQL_DATADIR
: Specify the MySQL data directory, the default is /usr/local/mysql/data. -
-DSYSCONFDIR
: Specify the MySQL configuration file directory, the default is /etc. -
-DWITH_MYISAM_STORAGE_ENGINE
: Enable the MyISAM storage engine. -
-DWITH_INNOBASE_STORAGE_ENGINE
: Enable the InnoDB storage engine. -
-DWITH_MEMORY_STORAGE_ENGINE
: Enable the Memory storage engine. -
-DWITH_READLINE
: Enable readline library. -
-DENABLED_LOCAL_INFILE
: Allows data to be imported from local files. -
-DMYSQL_UNIX_ADDR
: Specify the MySQL Unix socket file path, the default is /var/run/mysql/mysql.sock. -
-DMYSQL_TCP_PORT
: Specify the MySQL TCP listening port, the default is 3306.
- Run make and make install commands to compile and install MySQL
make make install
- Configure MySQL
Change the MySQL source code directory Copy the supporting files under to the MySQL installation directory:
cd /usr/local/mysql cp support-files/my-default.cnf /etc/my.cnf
Modify the MySQL configuration file my.cnf and add the following parameters:
[mysqld] basedir = /usr/local/mysql datadir = /usr/local/mysql/data socket = /var/run/mysql/mysql.sock
Step 6: Start MySQL
Start MySQL Service:
service mysqld start
Set MySQL to start automatically at boot:
chkconfig mysqld on
Step 7: Set the MySQL password
After the MySQL installation is completed, you need to set the password of the root user:
mysql_secure_installation
Follow the following steps according to the prompts:
- Enter the root password that needs to be set.
- Configure password security.
- Whether to delete anonymous users.
- Whether to prohibit root login through remote IP.
- Whether to delete the test database.
- Whether to reload the permission table.
The complete installation process is completed and MySQL can be used normally.
Summary
Using source code to install MySQL can more flexibly customize the configuration of MySQL than directly using binary packages. At the same time, you can also have an in-depth understanding of the working principle of MySQL from the source code level.
Through the introduction of this article, I believe that readers have mastered the basic process of installing MySQL source code on CentOS systems and can set it up according to their own needs. If you have any questions, please leave a message in the comment area.
The above is the detailed content of centos installation mysql source code. For more information, please follow other related articles on the PHP Chinese website!

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

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