What is the method to install MySQL8.0.32 on Centos7.9
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.
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 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
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
Modify the owner of the installation directory to mysql
chown -R mysql:mysql /usr/local/mysql/
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
The fourth step is to determine some related directories
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
Step 6. Start the database, connect and change the root password
sudo ./bin/mysqld --defaults-file=/etc/my.cnf --user=mysql
Connect to the database, change the root password
ALTER USER 'root'@'localhost' IDENTIFIED BY '你的密码';
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
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
# 使能 sudo systemctl enable mysql.service # 启动 sudo systemctl start mysql.service # 查看状态 sudo systemctl status mysql.service
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!

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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.

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

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 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.

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 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.

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

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.
