Table of Contents
mysql compilation and installation
Add user
Download the source package and unzip it
Install extension dependencies
Create mysql The installation directory and database storage directory
Compile and install mysql
Check whether the installation is successful
New directory
Add configuration file
Modify permissions
Generate initialization password
Add the mysql startup service to the system service
Start mysql
Modify mysql password, and remote connection permissions
Home Backend Development PHP Tutorial Compile and install mysql5.7 on linux

Compile and install mysql5.7 on linux

Jul 06, 2018 pm 03:15 PM
linux mysql php

This article mainly introduces about linux compilation and installation of mysql5.7, which has certain reference value. Now I share it with everyone. Friends in need can refer to it

mysql compilation and installation

Add user

useradd -s /usr/sbin/nologin -r mysql

Download the source package and unzip it

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.21.tar.gz
tar -zxf mysql-boost-5.7.21.tar.gz
cd mysql-5.7.21
Copy after login

Install extension dependencies

yum remove mariadb-libs
yum install gcc -y
yum install gcc-c++ -y
yum install cmake -y
yum install libaio -y
yum install ncurses-devel -y
Copy after login

Create mysql The installation directory and database storage directory

mkdir -p /data/db/mysql
mkdir -p /data/log/mysql
Copy after login

Compile and install mysql

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DSYSCONFDIR=/usr/local/mysql/etc \
-DMYSQL_DATADIR=/data/mysql \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_SYSTEMD=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost
make -j8 && make install
Copy after login

Check whether the installation is successful

[root@root mysql-5.7.12]#    cd /usr/local/mysql/
[root@root mysql]#    ls
bin      data  include  man         mysql.sock.lock  README  support-files
COPYING  docs  lib      mysql.sock  mysql-test       share
Copy after login

New directory

mkdir -p /data/db/mysql/
mkdir -p /data/log/mysql/
Copy after login

Add configuration file

mkdir /usr/local/mysql/etc
touch /usr/local/mysql/etc/my.cnf
ln -s /usr/local/mysql/etc/my.cnf /usr/local/etc
Copy after login

Modify permissions

chown -R mysql:mysql /usr/local/mysql/*
chown -R mysql:mysql /data/db/mysql /data/log/mysql
Copy after login

Generate initialization password

cd /usr/local/mysql
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/db/mysql
bin/mysql_ssl_rsa_setup
vim /data/log/mysql/error.log
查看初始化密码
grep 'temporary password' /data/log/mysql/error.log
Copy after login

Add the mysql startup service to the system service

cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system
mkdir -p /var/run/mysqld/
chown mysql:mysql /var/run/mysqld
systemctl start mysqld
service mysql start
Copy after login

Start mysql

service mysqld start
检查mysql启动是否正常
service mysqld status 或者 ps -ef | grep mysql
设置mysqld服务开机自启动
systemctl enable mysqld.service
检查mysqld开机自启动是否设置成功
systemctl list-dependencies | grep mysqld
Copy after login

Modify mysql password, and remote connection permissions

 ALTER USER 'root'@'localhost' IDENTIFIED BY 'Studytime%';
use mysql;
select host, user from user;
update user set host = '%' where user = 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Studytime%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone's learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Using PHP7.2 Data Structures

How to compile and install extended redis and swoole with php

The above is the detailed content of Compile and install mysql5.7 on linux. 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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

The Future of PHP: Adaptations and Innovations The Future of PHP: Adaptations and Innovations Apr 11, 2025 am 12:01 AM

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

PHP: Is It Dying or Simply Adapting? PHP: Is It Dying or Simply Adapting? Apr 11, 2025 am 12:13 AM

PHP is not dying, but constantly adapting and evolving. 1) PHP has undergone multiple version iterations since 1994 to adapt to new technology trends. 2) It is currently widely used in e-commerce, content management systems and other fields. 3) PHP8 introduces JIT compiler and other functions to improve performance and modernization. 4) Use OPcache and follow PSR-12 standards to optimize performance and code quality.

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

MySQL and SQL: Essential Skills for Developers MySQL and SQL: Essential Skills for Developers Apr 10, 2025 am 09:30 AM

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

How to learn Linux basics? How to learn Linux basics? Apr 10, 2025 am 09:32 AM

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.

MySQL: A User-Friendly Introduction to Databases MySQL: A User-Friendly Introduction to Databases Apr 10, 2025 am 09:27 AM

The installation and basic operations of MySQL include: 1. Download and install MySQL, set the root user password; 2. Use SQL commands to create databases and tables, such as CREATEDATABASE and CREATETABLE; 3. Execute CRUD operations, use INSERT, SELECT, UPDATE, DELETE commands; 4. Create indexes and stored procedures to optimize performance and implement complex logic. With these steps, you can build and manage MySQL databases from scratch.

How to open phpmyadmin How to open phpmyadmin Apr 10, 2025 pm 10:51 PM

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

See all articles