Home > Database > Mysql Tutorial > body text

mysql compressed package installation

WBOY
Release: 2023-05-18 09:52:37
Original
3801 people have browsed it

MySQL is a widely used relational database management system, often used for data storage and management of websites or applications. MySQL is widely used, both by individual developers and large enterprises.

MySQL installation can be achieved in a variety of ways, such as through binary installation packages, yum package managers, docker images, etc. However, if you want to install MySQL through a compressed package, this article will introduce how to install the compressed package of MySQL in a Linux system.

About MySQL compressed package

MySQL compressed package is a very convenient way to install MySQL. The MySQL compressed package is a compiled binary file package, which contains the MySQL server program, MySQL client program, MySQL management program, etc., and can be directly decompressed to a specified location for use. The MySQL installation package is usually in .tar.gz or .zip format, and we can download it from the official website.

Step 1: Download the MySQL compressed package

The MySQL compressed package can be found on the MySQL official website download page at https://dev.mysql.com/downloads/mysql/. Select the corresponding compressed package according to the required version and platform. This article takes version 5.7 as an example.

After clicking to enter the page, you will see a list of files that can be downloaded, just select the file you need.

Step 2: Prepare the installation program

After the download is completed, we need to decompress the MySQL compressed package. After decompression, you can find a file similar to mysql-5.7.28-linux-glibc2.12-x86_64. tar.gz file. We need to decompress the file to a specified location (for example, the /opt directory), use the following command:

sudo tar -zxvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -C /opt
Copy after login

This command will decompress the compressed file to the /opt directory. After decompression, you can see the .mysql and data directories. The .mysql directory corresponds to the MySQL configuration file directory, and the data directory is the directory where MySQL stores data.

Step 3: Create a MySQL user

We need to add a MySQL user to run the MySQL service in a secure manner. Create a MySQL user through the following command:

sudo groupadd mysql
sudo useradd -r -g mysql mysql
Copy after login

After the creation is completed, we need to set the access permissions for the MySQL data directory and configuration file directory for the user. Pass the following command:

sudo chown -R mysql:mysql /opt/mysql-5.7.28-linux-glibc2.12-x86_64/.mysql /opt/mysql-5.7.28-linux-glibc2.12-x86_64/data
Copy after login

Step 4: Set the MySQL environment variable

In order to facilitate subsequent use, we need to add the MySQL execution file directory to the environment variable PATH. Pass the following command:

echo 'export PATH=$PATH:/opt/mysql-5.7.28-linux-glibc2.12-x86_64/bin' >>~/.bashrc
source ~/.bashrc
Copy after login

Step 5: Configure MySQL

After the installation is completed, we need to complete the basic settings of MySQL through the configuration file. The my.cnf file can be found in the mysql-5.7.28-linux-glibc2.12-x86_64/.mysql directory, which is the configuration file of MySQL. We can modify the parameters in the configuration file according to actual needs.

By default, the MySQL server serves all IP addresses. If you need to specify an IP address, you can add the following parameters to the configuration file:

bind-address=127.0.0.1
Copy after login

Step 6: Start MySQL

We can start the MySQL service in the following way:

sudo /opt/mysql-5.7.28-linux-glibc2.12-x86_64/bin/mysqld_safe &
Copy after login

This command will start the MySQL service as a background process. We can check the MySQL service status through the following command:

sudo /opt/mysql-5.7.28-linux-glibc2.12-x86_64/bin/mysqladmin -u root -p status
Copy after login

This command will prompt you to enter the password of the root user, and then the MySQL service status information will be displayed.

Step 7: Change the login password

After the installation of the MySQL service is completed, the default root user password is empty and needs to be modified. Enter the MySQL service through the following command:

mysql -u root
Copy after login

After entering, you can see the MySQL prompt. At this time, enter the following command to change the password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Copy after login

Among them, new_password is the new password you want to set.

Installation Complete

Now, through the above steps, we have successfully installed the MySQL compressed package version on the Linux system. The next step is to start MySQL, try to create a database, perform data operations, etc.

Summary

MySQL compressed package installation is not complicated. It only takes a few simple steps to install the MySQL service on a Linux system. Through the method introduced in this article, you can learn about the MySQL compression package installation method, and you can also make corresponding modifications during actual use. I hope this article is helpful for beginners.

The above is the detailed content of mysql compressed package installation. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template