How to install linux mysql tar

PHPz
Release: 2023-04-17 17:29:22
Original
2115 people have browsed it

There are usually many ways to install MySQL database in Linux systems, including source code compilation, binary installation and use of package managers. However, this article will introduce the installation method of MySQL database through Tar package in Linux system. Below, this article will introduce the installation process of MySQL database through Tar package step by step, and provide some practical commands for readers' reference.

  1. Download MySQL Tar package
    Before installing MySQL, we need to download the precompiled binary file ( Tar bag). On the download page, select the version and appropriate architecture for your operating system. This article takes the Linux system as an example and selects the Linux-Generic version.
  2. Decompress the MySQL Tar package
    After the download is completed, we need to decompress the MySQL Tar package file into the system. Use the following command to decompress the MySQL Tar package:

tar -xzvf mysql-x.x.xx-linux-glibc2.12-x.xx.tar.gz

where x.x.xx represents The version number of MySQL may change. After executing the above command, a mysql-x.x.xx-linux-glibc2.12-x.xx folder will be generated, which contains all files and directories of MySQL.

  1. Configure MySQL database
    After decompression is completed, enter the mysql-x.x.xx-linux-glibc2.12-x.xx directory and use the following command to create a MySQL user:

useradd mysql

Copy the files in the MySQL folder to the system directory:

cp -R ./mysql-x.x.xx-linux-glibc2.12-x.xx /usr/ local/mysql

Copy the MySQL configuration file my.cnf to the /etc directory:

cp /usr/local/mysql/support-files/my-default.cnf /etc/my .cnf

Use the following command to update the data directory permissions in MySQL:

chown -R mysql:mysql /usr/local/mysql

  1. Initialize the MySQL database
    After configuring the MySQL database in the third step, you need to execute the following command to initialize the MySQL database:

cd /usr/local/mysql
./bin/mysqld --initialize -- user=mysql

This command will generate the MySQL root password, which is stored in the error.log file.

  1. Start the MySQL service
    Start the MySQL service through the following command:

systemctl start mysqld

  1. Set the MySQL root password
    After starting the MySQL service, we need to set the newly generated MySQL root password to a password that we can manage.

Use the following command to modify:

mysqladmin -u root password 'newpassword'

Among them, 'newpassword' represents the new password.

  1. Set up MySQL for remote access
    If you need to access the MySQL database from a remote computer, you need to execute the following command to bind MySQL to the public IP address:

vi /etc/my.cnf

Add the following parameters in the file:

bind-address=your-server-ip

your-server-ip within the quotation marks refers to The public IP address of this machine, not the local unique address 127.0.0.1.

  1. Common commands
    After completing the above steps, we need to learn some common MySQL commands.

Start the MySQL service:

systemctl start mysqld

Stop the MySQL service:

systemctl stop mysqld

Restart the MySQL service :

systemctl restart mysqld

View MySQL service status:

systemctl status mysqld

Enter MySQL:

mysql -u root - p

Exit MySQL:

exit

The above is the process and common commands for installing the MySQL database through the Tar package introduced in this article. Although this method is relatively complicated, it allows you to have a deeper understanding of the MySQL database and learn to use some practical commands.

The above is the detailed content of How to install linux mysql tar. 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!