Home > Database > Mysql Tutorial > Steps to install MySQL using RPM package manager on Linux

Steps to install MySQL using RPM package manager on Linux

PHPz
Release: 2023-04-19 15:04:56
Original
617 people have browsed it

Linux RPM MySQL Installation

MySQL is a widely used open source relational database system that supports multi-threaded processing and many different storage engines. This article will describe the steps to install MySQL on Linux using the RPM package manager.

Preparation

Before starting, please make sure you have root permissions on the Linux system and have installed the RPM package management tool. If you use an RPM-based Linux distribution such as Red Hat or CentOS, you can use the following command to obtain it:

yum update && yum install rpm
Copy after login

Download the MySQL RPM installation package

Download from the MySQL official website for your system RPM installation packages for architectures and distributions. In this tutorial, we will download MySQL Community Server for CentOS 7, 64-bit system. You can download the corresponding installation package from the MySQL official website.

Install MySQL

After downloading, use the following command to install MySQL:

rpm -ivh mysql-community-server-version.el7.architecture.rpm
Copy after login

Note: Please use the actual installation package name, version number and architecture instead of the version in the example number and architecture.

During the installation process, you will be prompted to enter your root password. Please make sure not to forget this password as it is the administrator password for the MySQL system.

Start MySQL

After the installation is complete, you need to start the MySQL service:

systemctl start mysqld.service
Copy after login

If you want MySQL to start automatically at boot, you can use the following command:

systemctl enable mysqld.service
Copy after login

Configuring MySQL

After starting MySQL, you need to log in to MySQL using the root account. The following command will enter the MySQL system:

mysql -u root -p
Copy after login

Enter your password and you can start configuring MySQL.

First of all, in order to ensure the security of the system, you need to change the root account password:

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

Please replace "NewPassword" with your new password.

Next, run the following command to secure your MySQL instance:

mysql_secure_installation
Copy after login

This command will prompt you to configure the following:

  1. Change the MySQL root account password ;
  2. Delete anonymous users;
  3. Disable root remote login;
  4. Delete the test database;
  5. Reload the privilege table.

Just follow the prompts to configure.

The next step is to update the MySQL configuration file. Follow these steps:

  1. Open the MySQL configuration file:
nano /etc/my.cnf
Copy after login
  1. Find the following line and comment it out:
# skip-networking
Copy after login

This will ensure that the MySQL server can be connected via the network.

  1. Save changes and exit the editor.

Restart MySQL

Finally, you need to restart the MySQL service to ensure that the changes take effect:

systemctl restart mysqld.service
Copy after login

Now, you have successfully used the RPM package manager MySQL is installed on the Linux system. You can interact with MySQL using mainstream development languages ​​such as PHP, Python, and Java.

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