Table of Contents
Step one, download the compressed package
The second step is to decompress the compressed package and copy it to the installation directory.
The third step is to edit the configuration file
The fourth step is to determine some related directories
The fifth step, initialize the database
Step 6. Start the database, connect and change the root password
The sixth step, protect the MySQL process
Step 7, Verification
Home Database Mysql Tutorial What is the method to install MySQL8.0.32 on Centos7.9

What is the method to install MySQL8.0.32 on Centos7.9

May 30, 2023 pm 01:46 PM
mysql centos

Step one, download the compressed package

Download the community version of MySQL and download the corresponding version according to your needs, including the minimum installation version.

What is the method to install MySQL8.0.32 on Centos7.9

The second step is to decompress the compressed package and copy it to the installation directory.

Go to the folder where the compressed package is located and decompress it twice. Extract the xz file once and the tar file a second time.

xz -dv mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz
tar -xvf mysql-8.0.32-linux-glibc2.12-x86_64.tar
Copy after login

Copy the decompressed file to the directory where you want to install it. I want to install MySQL to /usr/local/mysql, so run the following command and copy the decompressed file there

sudo cp -r mysql-8.0.32-linux-glibc2.12-x86_64/* /usr/local/mysql
Copy after login

Here we need to modify the permissions of the following installation directory. Since we use the mysql user to run the database, we need to change the owner of the installation directory to mysql. If the system does not have it, we need to add the mysql user and group. We only use mysql to run the program. Therefore, mysql is specified to prohibit login and increase security

sudo groupadd mysql
sudo useradd mysql -s /usr/sbin/nologin -g mysql
Copy after login

Modify the owner of the installation directory to mysql

chown -R mysql:mysql /usr/local/mysql/
Copy after login

The third step is to edit the configuration file

Edit the configuration file, we Place the configuration file in /etc/my.cnf

The configuration is as follows:

[client]
port=3306
# 端口
# mysqlx_port=33060
socket=/var/lib/mysql/mysql.sock
# mysqlx_socket=/var/lib/mysqlx.sock

[mysqld]
# skip-grant-tables
# mysql安装目录
basedir=/usr/local/mysql/
# mysql数据库目录
datadir=/var/lib/mysql/data/
port=3306
innodb_file_per_table=1
character-set-server=UTF8MB4
mysqlx_port=33060
socket = /var/lib/mysql/mysql.sock
# mysqlx_socket=/var/lib/mysql/mysqlx.sock

[mysqld_safe]
# 错误日志
log-error=/var/log/mysql/error.log
# pid文件
pid-file=/usr/local/mysql/mysqld.pid
tmpdir=/var/lib/mysql/mysql
Copy after login

Edit the file support-files/mysql. server, modify the relevant directories inside

Installation directory basedir=/usr/local/mysql

Configuration directory/etc/my.cnf

Database file directory datadir=/var /lib/mysql/data/

pid file pid-file=/usr/local/mysql/mysqld.pid

The fifth step, initialize the database

Initialize the database, Note that after successful initialization, the terminal will display the root account password, which must be saved

sudo ./bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --initialize
Copy after login

Step 6. Start the database, connect and change the root password

sudo ./bin/mysqld --defaults-file=/etc/my.cnf --user=mysql
Copy after login

Connect to the database, change the root password

ALTER USER 'root'@'localhost' IDENTIFIED BY '你的密码';
Copy after login

The sixth step, protect the MySQL process

Create a daemon program to ensure that it can start automatically after the server is restarted. Run

sudo vim /etc/systemd/system/mysql.service
Copy after login

The content is as follows, where User and Group are mysql

[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
#Restart=on-failure
#RestartPreventExitStatus=1
#PrivateTmp=false
Copy after login
# 使能
sudo systemctl enable mysql.service
# 启动
sudo systemctl start mysql.service
# 查看状态
sudo systemctl status mysql.service
Copy after login

Step 7, Verification

Restart the server to verify whether the mysql process is started

The above is the detailed content of What is the method to install MySQL8.0.32 on Centos7.9. 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)

MySQL's Role: Databases in Web Applications MySQL's Role: Databases in Web Applications Apr 17, 2025 am 12:23 AM

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

How to start mysql by docker How to start mysql by docker Apr 15, 2025 pm 12:09 PM

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

Centos shutdown command line Centos shutdown command line Apr 14, 2025 pm 09:12 PM

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

Laravel Introduction Example Laravel Introduction Example Apr 18, 2025 pm 12:45 PM

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

How to install mysql in centos7 How to install mysql in centos7 Apr 14, 2025 pm 08:30 PM

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

Centos stops maintenance 2024 Centos stops maintenance 2024 Apr 14, 2025 pm 08:39 PM

CentOS will be shut down in 2024 because its upstream distribution, RHEL 8, has been shut down. This shutdown will affect the CentOS 8 system, preventing it from continuing to receive updates. Users should plan for migration, and recommended options include CentOS Stream, AlmaLinux, and Rocky Linux to keep the system safe and stable.

Centos configuration IP address Centos configuration IP address Apr 14, 2025 pm 09:06 PM

Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

Solve database connection problem: a practical case of using minii/db library Solve database connection problem: a practical case of using minii/db library Apr 18, 2025 am 07:09 AM

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

See all articles