Home > Database > Mysql Tutorial > How to install MySQL on Linux system using RPM package

How to install MySQL on Linux system using RPM package

PHPz
Release: 2023-04-19 15:09:01
Original
676 people have browsed it

On the Linux operating system, the MySQL database is a very popular relational database. There may be many ways to install a MySQL database, one of which is to install MySQL through an RPM package. RPM is a software package manager used to install, upgrade and remove software packages on the Red Hat base operating system. This article will introduce how to install MySQL on a Linux system using RPM packages.

  1. Download MySQL RPM package

First, we need to download the RPM package for our operating system from the MySQL official website. It is important to choose the right RPM package, especially one that is compatible with the operating system and version. Now we assume that we are installing the CentOS 7 operating system, so we need to select the RPM package for CentOS 7.

  1. Install the MySQL RPM package

After downloading the RPM package, we can use the following command to install it:

sudo rpm -ivh <path-to-RPM-package>
Copy after login

where<path- to-RPM-package> is the path to the RPM package we downloaded. For example, if we download the RPM package into the ~/Downloads folder, then we will install it using the following command:

sudo rpm -ivh ~/Downloads/mysql57-community-release-el7-9.noarch.rpm
Copy after login

During the installation process, we will see some output, Such as:

Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql57-community-release-el7-9  ################################# [100%]
Copy after login

This means that we have successfully installed the MySQL RPM package.

  1. Install MySQL server

The MySQL RPM package contains a package named mysql-community-server, which contains the MySQL server all content. Therefore, we can use the following command to install the MySQL server:

sudo yum install mysql-community-server
Copy after login
  1. Start the MySQL service

After installing the MySQL server, we need to use the following command to start the MySQL service:

sudo systemctl start mysqld
Copy after login

At this point, the MySQL server will be up and running.

  1. Verify MySQL Server

After installing and starting the MySQL server, we need to verify that it is available. We can use the following command to check whether the MySQL server has been installed correctly:

sudo systemctl status mysqld
Copy after login

This will output the status information of the MySQL server. If the MySQL server is properly installed and running, we should be able to see the following output:

● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2021-05-07 14:43:49 CST; 3s ago
  Process: 3707 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 3709 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─3709 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Copy after login

This indicates that the MySQL server is running and ready for use.

  1. Set the MySQL root password

After installing the MySQL server, we need to set the password of the MySQL root user. We can use the following command to set the password:

sudo mysql_secure_installation
Copy after login

This command will start the MySQL Secure Installation Wizard, which will prompt us to enter a new password. After entering the password, we need to follow the prompts to make some other settings, such as disabling anonymous access and deleting the test database.

  1. Login to the MySQL database

After installing and setting up the MySQL server, we can log in to the MySQL database using the following command:

mysql -u root -p
Copy after login

This command will prompt us to enter The password of the MySQL root user. After entering the password, we will enter the MySQL Shell where we can execute MySQL commands and queries.

Now we have successfully installed the MySQL database on the Linux system using the RPM package. You can also use RPM packages to install MySQL databases on other operating systems such as Ubuntu, Debian, and Fedora. Before installing MySQL, make sure to select the correct RPM package for the operating system you are using, and make sure to follow the appropriate installation, startup, and setup guidelines.

The above is the detailed content of How to install MySQL on Linux system using RPM package. 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