Home > Database > Mysql Tutorial > body text

How to install mysql in linux rpm

PHPz
Release: 2023-04-21 14:07:20
Original
2738 people have browsed it

There are many ways to install MySQL on a Linux system, one of which is to use rpm installation. This article will introduce how to install MySQL through rpm.

1. Preparation

Before starting, first confirm whether MySQL and MariaDB already exist in the system. You can check it by running the following command:

rpm -qa | grep mysql
rpm -qa | grep mariadb
Copy after login

If they already exist, you need to Uninstall it through the command first.

2. Download the MySQL software package

Go to the MySQL official website to download the required rpm software package and choose the version that suits you. After the download is completed, upload the rpm package to the server. It can be uploaded to any directory.

3. Install MySQL

Use the following command to install MySQL:

rpm -ivh mysql-community-common-8.0.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.22-1.el7.x86_64.rpm
Copy after login

Dependency errors may occur during the installation process, and missing dependencies need to be installed.

4. Start and configure MySQL

After the installation is completed, you need to perform some configuration and startup operations on MySQL. Execute the following command to start MySQL:

systemctl start mysqld
Copy after login

Check the status of MySQL:

systemctl status mysqld
Copy after login

After the startup is completed, you can check the initial password of MySQL through the following command:

grep 'temporary password' /var/log/mysqld.log
Copy after login

Log in to MySQL

Use the following command to log in to MySQL and change the password:

mysql -uroot -p

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

5. Firewall configuration

If the system has a firewall enabled and you need to open the MySQL service port, use the following command to open port 3306 :

firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --reload
Copy after login

At this point, the process of rpm installation of MySQL is completed.

Summary

Installing MySQL through rpm may cause dependency errors, so you need to pay attention to installing missing dependencies. After the installation is complete, some configuration and startup operations are required for MySQL before it can be used normally. At the same time, if the system uses a firewall, the port of the MySQL service also needs to be opened, otherwise remote connection cannot be made.

The above is the detailed content of How to install mysql in linux rpm. 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