Home  >  Article  >  Database  >  How to use yum command to install MySQL in Linux

How to use yum command to install MySQL in Linux

PHPz
PHPzOriginal
2023-04-21 11:20:48806browse

Linux is a very popular operating system that is widely used in various servers and development environments. In Linux, MySQL is one of the most popular relational databases, and it is very convenient to use the yum command to install MySQL in Linux.

The following are the steps to use yum to install the MySQL database in a Linux system.

  1. First, you need to start the terminal in the Linux system and log in with the root user.
  2. Next, you need to install the MySQL warehouse yum installation package. Please note that this command needs to be run on your version of Linux. For example, on a CentOS 7 system, you need to use the following command to install the MySQL 8 repository:
sudo yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
  1. After installing the yum installation package, you can use the following command to refresh your yum source :
sudo yum update
  1. Next, you can use the following command to find the version of the MySQL package:
sudo yum search mysql
  1. If you want to install MySQL 8, You can use the following command:
sudo yum install mysql-community-server
  1. After installing MySQL, you need to start the MySQL service. You can start it using the following command:
sudo systemctl start mysqld
  1. To check if MySQL is running, use the following command:
sudo systemctl status mysqld
  1. Next, You need to set up security settings for MySQL. You can start the mysql_secure_installation script using the following command:
sudo mysql_secure_installation

The script will guide you through a series of MySQL configuration options. For example, you can reset the root account password to improve database security. Additionally, you can choose to delete anonymous users and test databases to improve the security of your system.

  1. Finally, you can use the following command to connect to the MySQL database:
sudo mysql -u root -p

You will be prompted for the password for MySQL root. If you have successfully logged in, you will be able to perform various operations using MySQL's command line interface.

In short, using yum to install MySQL in Linux is a very simple task. Using the above steps you will be able to quickly and easily install MySQL, configure security, and start using this popular relational database.

The above is the detailed content of How to use yum command to install MySQL in Linux. 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