Home  >  Article  >  Database  >  How to install linux mysql through RPM

How to install linux mysql through RPM

PHPz
PHPzOriginal
2023-04-20 10:07:081021browse

MySQL under Linux system is a common database management system, mainly used to store and manage large amounts of data. Installing MySQL on Linux requires some skills. This article will mainly introduce how to install it through RPM.

1. Download the RPM of MySQL

Before installing MySQL, we need to download the MySQL RPM file suitable for our system from the official website. Visit the official website, find the RPM file of the corresponding version, and download it to your local hard drive.

2. Install MySQL RPM

After the download is completed, we can start installing MySQL. There are several installation methods:

  1. The easiest way is to double-click the RPM file and follow the prompts to install.
  2. Open the terminal, enter the downloaded directory, and execute the following command:

sudo rpm -ivh MySQL-server-*.rpm

  1. If If you want to upgrade MySQL, you need to execute the following command:

sudo rpm -Uvh MySQL-server-*.rpm

  1. If you need to install MySQL and its client at the same time , you can execute the following command:

sudo rpm -ivh MySQL-client-.rpm MySQL-server-.rpm

This way you can install MySQL and Its a client too.

3. Configure MySQL

After the installation of MySQL is completed, let’s perform some simple configurations for it.

  1. Start MySQL

sudo systemctl start mysqld.service

  1. Set auto-start on boot

sudo systemctl enable mysqld.service

  1. Configure MySQL root password

MySQL does not have a password by default after the installation is completed. We need to set a password for it through the following command:

sudo /usr/bin/mysql_secure_installation

Press Enter to continue. You will be prompted to enter the current root user password. Because this is a newly installed MySQL, just enter the key here

Then the program will prompt you to enter the root user password, and then confirm the password again.

The program will then ask whether to delete the test database. For security reasons, you can choose to delete the test database.

  1. Login to MySQL

mysql -u root -p

  1. Close MySQL

sudo systemctl stop mysqld .service

At this point, the MySQL installation and some simple configurations are completed. We can start using this database for data storage and management.

The above is the detailed content of How to install linux mysql through RPM. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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