search
HomeDatabaseMysql TutorialHow to compile Mysql5.7.11 through Systemd

How to compile Mysql5.7.11 through Systemd


MySQL 5.7 main features:

Native support for Systemd Better performance: for multi-core CPUs, solid-state drives, The lock has a better optimized InnoDB storage engine and a more robust replication function: replication brings no data loss at all, and traditional financial customers can also choose to use the MySQL database. In addition, GTID online smooth upgrade also becomes possible with a better optimizer: the significance of optimizer code reconstruction will bring huge improvements in this version and subsequent versions, Oracle officials are solving the biggest problem before MySQL native JSON type Support better geographical information service support: InnoDB natively supports geographical location types, supports GeoJSON, and GeoHash features. New sys library: This will be the most frequently accessed library by DBAs in the future. MySQL 5.7 has been added to OneinStack as a database option - lnmp In the installation tool

Install dependency packages

yum -y install make gcc-c++ cmake bison-devel ncurses-devel

Download the mysql source package

There are two versions of the source package: mysql- 5.7.11.tar.gz does not come with the boost library and needs to be downloaded by yourself.

mysql-boost-5.7.11.tar.gz comes with the boost library. It is recommended to download it in the root directory after decompression. wget http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.11.tar.gz

curl -O http://cdn.mysql .com/Downloads/MySQL-5.7/mysql-boost-5.7.11.tar.gz

tar -zxf mysql-boost-5.7.11.tar.gz

cd mysql-5.7 .11

Compile

Generate makefile "

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 \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -D EXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ [Character set] -DDEFAULT_COLLATION=utf8_general_ci \ [Collation rules must be present, otherwise it will be difficult to initialize the database] -DDOWNLOAD_BOOST=1 \ [The Boost library is required starting from MySQL 5.7.5] -DWITH_BOOST=/root/mysql-5.7.11/ boost \ -DWITH_SYSTEMD=1 [Support Systemd] Adding -DWITH_SYSTEMD=1 can use systemd to control the mysql service. Systemd is not enabled by default.

Thenmake -j 2 && make install mysql will be installed to the /usr/local/mysql path and wait slowly...

Configure MySQL

Add mysql user and group

groupadd mysql

useradd -g mysql -s /sbin/nologin mysql

Modify /usr/local/mysql permissions

chown -R mysql:mysql /usr/local/mysql

Create mysql PID default directory

In mysqld.service, the default pid file is assigned to the /var/run/mysqld/ directory, but the directory is not created in advance, so the directory must be created manually and the permissions Assigned to the mysql user. mkdir -p /var/run/mysqldchown mysql:mysql /var/run/mysqld

mysql The default location of the three running files

log : /var/log/mysqld.logpid : /var/run/mysqld/mysqld.pidsock : /tmp/mysql.sock

Copy my.cnf and mysqld.service

cp support-files/my-default.cnf /etc/my.cnf

mysql 5.7 by default installs the mysqld.service (/usr/local/mysql/) file to usr/lib/systemd in the mysql installation directory /system/, copy mysqld.service to the /usr/lib/systemd/system/ directory [root@localhost]/usr/local/mysql#cp usr/lib/systemd/system/mysqld.service /usr /lib/systemd/system

Add environment variables

— Edit the /etc/profile file and add the following two lines at the end— “

vim /etc/profile

PATH=/usr/local/mysql/bin:$PATH export PATH

source /etc/profile

Initialization Passwordless mysql database

bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/ databin/mysql_ssl_rsa_setup The following content appears, initialization is successful 2016-02-22T03:56:27.254356Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the –initialize-insecure option.

-–initialize will generate a random password (saved in ~/.mysql_secret), while -–initialize-insecure will not generate a password. When setting the password in the MySQL security configuration wizard mysql_secure_installation, you can freely select the mysql password level .

-–There cannot be data files in the datadir target directory.

The previous version initialization program mysql_install_db is under /usr/local/mysql/script and will be removed in the future. Mysqld will be used instead. The deprecated mysql5.7 is placed in /usr/local/ mysql/bin directory.

Start mysql

systemctl start mysqld.service

systemctl status mysqld.service

Run the MySQL security configuration wizard mysql_secure_installation Set password , the mysql service can only be executed after starting

a) Set a password for the root user b) Delete the anonymous account c) Cancel the remote login of the root user d) Delete the test library and access rights to the test library e) Refresh the authorization table Make the modification effective[root@localhost mysql]# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password. [使用空密码连接到MySQL]

VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin?[VALIDATE密码插件可以被用来测试密码 并提高安全性。你是否想设置VALIDATE密码插件?]

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy: [有三种级别的密码验证策略:]

LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file [最小长度> = 8 中等长度> = 8,数字,大小写混合和特殊字符 最长长度> = 8,数字,混合大小写,特殊字符和字典文件]

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 [请输入0 =低,1 =中2 =强:0] Please set the password for root here. [请在这里设置root用户的密码。]

New password: [新密码:]

Re-enter new password: [重新输入新密码:]

Estimated strength of the password: 25 [密码的估计强度:25] Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y [您是否希望继续与提供的密码(按y | Y表示是,因为没有任何其他键):Y?] … Failed! Error: Your password does not satisfy the current policy requirements [ … 失败!错误:您的密码不符合当前的要求]

New password:

Re-enter new password:

Estimated strength of the password: 50 [密码的估计强度:50] Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. [默认情况下,MySQL安装有一个匿名用户, 允许任何人登录到MySQL.]

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y [删除匿名用户?] Success. [成功。]

Normally, root should only be allowed to connect from ‘localhost’. This ensures that someone cannot guess at the root password from the network. [通常情况下,Root 只允许其进行’localhost'(本地) 连接 。]

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n [禁止远程root登录?]

...omitting. [省略]。] By default, MySQL comes with a database named ‘test’ that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. [默认情况下,MySQL带有一个名为“测试”数据库,任何人都可以访问。这也是仅用于测试,并且应该移动到生产之前被删除环境。]

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n [删除测试数据库和访问权限?]

... omitting. [ ...省略。] Reloading the privilege tables will ensure that all changes made so far will take effect immediately. [刷新授权表以确保所有的变化取得将立即生效。]

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : [现在刷新授权表?]

… skipping. All done! [全部完成!]

开放 Root 远程连接权限

mysql -u root -p
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; [password 为远程连接密码]
mysql>FLUSH PRIVILEGES; [刷新权限]

The above is the detailed content of How to compile Mysql5.7.11 through Systemd. 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
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

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.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 19, 2025 am 12:22 AM

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.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

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: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

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: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

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: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

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.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

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.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

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

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

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

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools