In Linux systems, MySQL is a very common relational database management system. When installing MySQL, we can choose to install it through a tar compressed package. Next, this article will introduce in detail the process of installing MySQL through tar in Linux systems.
Step one: Download the MySQL installation package
First, we need to download the MySQL installation package from the official MySQL website. On the download page, you can choose the following MySQL version:
In this article, we chose the Community Edition 5.7 version of MySQL for installation. After selecting the corresponding version, we need to click the "Download" button to download.
Step 2: Decompress the MySQL installation package
After the download is completed, we need to decompress the MySQL compressed package. The unzipped folder contains all MySQL installation files. When decompressing, we can use the following command:
tar zxvf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
Among them, mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz is the name of the MySQL installation package we downloaded. After using this command, you can decompress the file and generate a folder named mysql-5.7.34-linux-glibc2.12-x86_64.
Step 3: Install MySQL
After decompression, we move the mysql-5.7.34-linux-glibc2.12-x86_64 folder to the directory where we want to install MySQL. After moving the folder, we need to enter the folder:
cd /usr/local cp -r /path/to/mysql-5.7.34-linux-glibc2.12-x86_64 .
After entering the mysql-5.7.34-linux-glibc2.12-x86_64 folder, we need to perform the initialization settings of MySQL. We can use the following command to initialize and configure the root user:
cd mysql-5.7.34-linux-glibc2.12-x86_64 ./bin/mysqld --initialize --user=mysql ./bin/mysql_secure_installation
In the above command, we used the mysqld command to initialize MySQL. After the initialization is completed, we need to use the mysql_secure_installation command to set the root user's password, permissions and other information.
Step 4: Start the MySQL service
Start the MySQL service through the following command:
./bin/mysqld_safe &
After starting the service, we need to use the following command to log in to MySQL:
./bin/mysql -u root -p
At this point, the system will prompt us to enter the root user password we set previously. After successfully logging in, we can happily use MySQL.
Summary:
Through the above method, we introduced in detail how to install MySQL through tar in the Linux system and perform the corresponding initialization settings and operations. It should be noted that when using MySQL, we must pay attention to the security and stability of the environment. At the same time, we must also understand as much as possible the specific operations of MySQL and its security issues.
The above is the detailed content of linux tar installation mysql. For more information, please follow other related articles on the PHP Chinese website!