Home > Database > Mysql Tutorial > How to use yum to install mysql on centos 7

How to use yum to install mysql on centos 7

PHPz
Release: 2023-04-21 11:48:31
Original
1620 people have browsed it

CentOS is a free and open source operating system compiled based on the Red Hat Enterprise Linux (RHEL) source code. It is also one of the most popular Linux distributions currently. MySQL is a popular relational database that is widely used in the development and deployment of web applications.

The easiest way to install MySQL on CentOS 7 is to use the Yum package manager. Yum is an automated package management tool that can install, update and delete software packages, while also automatically handling dependencies between software packages.

This article will introduce you how to install MySQL on CentOS 7 using Yum.

Step 1: Update the system

Before we begin, we need to update the system to ensure that the installed package versions are the latest. Update the system using the following command:

sudo yum update
Copy after login

Step 2: Install MySQL

Before installing MySQL, we need to download the MySQL Yum Repository configuration file. Execute the following command:

sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
Copy after login

This will import the MySQL Yum Repository configuration file into our system.

MySQL can now be installed via the following command:

sudo yum install mysql-community-server
Copy after login

If you need to install a specific version of MySQL, please execute the following command:

sudo yum install mysql-community-server-<version>
Copy after login

During the installation process, the system will prompt Do you want to install MySQL related dependencies? Type "y" and press "Enter" to continue.

Step 3: Start MySQL

After the MySQL installation is completed, we need to start the MySQL service and set it to start automatically. Execute the following command:

sudo systemctl start mysqld
sudo systemctl enable mysqld
Copy after login

Use the following command to check the status of the MySQL service:

sudo systemctl status mysqld
Copy after login

If the MySQL service is running, the message "Active: active (running)" will be displayed. Otherwise, check the error message to learn the cause of the problem.

Step 4: Set up MySQL

After installing and starting MySQL, we need to set up MySQL to protect its security. Execute the following command to run the MySQL Installation Wizard:

sudo mysql_secure_installation
Copy after login

The command will prompt you to do the following:

  • Disable remote login for the root user
  • Delete the anonymous user account
  • Delete the test database
  • Update the root user password

Follow the prompts to ensure the security of MySQL.

Step 5: Using MySQL

Now, you are ready to use MySQL. The following are some basic MySQL commands:

  • mysql -u root -p: Use the root user to log in to MySQL
  • show databases; : List all MySQL databases
  • use <database_name>;: Select the database to be used
  • show tables;: List the current All tables in the database
  • select * from <table_name>;: Select all data in the specified table

In this article, we show you Learn how to install MySQL on CentOS 7 using Yum. MySQL is a popular relational database that is widely used for the development and deployment of web applications. Before installing MySQL, please ensure that the Yum package manager has been installed on the system and the system has been updated to the latest version.

The above is the detailed content of How to use yum to install mysql on centos 7. 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