Home  >  Article  >  Database  >  How to install and configure MySQL database in Linux environment

How to install and configure MySQL database in Linux environment

PHPz
PHPzOriginal
2023-04-17 15:29:44632browse

In modern Internet applications, databases are an indispensable part. MySQL is widely used as one of the preferred databases for many applications. This article will introduce how to install and configure a MySQL database in a Linux environment.

Confirm system environment

MySQL can run on a variety of operating systems, including Linux, Windows and Mac OS. In this article, we will use Linux system for demonstration.

Before you start, you need to confirm whether the system environment meets the installation requirements of MySQL. Please make sure that the gcc and make packages are installed on your system. These packages are usually found in the default software repositories of most Linux distributions.

Download MySQL

MySQL can be downloaded from the official website or through the terminal command line. This article will demonstrate the latter approach.

Open the terminal and enter the following command:

$ wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

This command will download the MySQL official yum repository installation package.

Install MySQL

After the download is completed, use the following command to install MySQL:

$ sudo rpm -ivh mysql80-community-release-el7-3.noarch.rpm

After executing this command, the system will add the MySQL repository to the system.

Next, use the following command to install MySQL Community Server:

$ sudo yum install mysql-community-server

After executing this command, the system will start to download and install the MySQL database. After the installation is completed, you need to start MySQL:

$ sudo systemctl start mysqld

Configuring MySQL

After the MySQL installation is completed, you need to configure it. First, you need to use the following command to create an administrator account in the MySQL database:

$ sudo mysql_secure_installation

Next, enter the administrator password and other information as prompted. After completion, run the following command to log in to the MySQL server:

$ mysql -u root -p

In the MySQL command line, you can enter SQL statements to perform database operations.

Summary

This article introduces the process of installing and configuring a MySQL database in a Linux environment. MySQL is a powerful database software that provides many advanced functions and tools to help developers manage and maintain application databases more easily. I hope this article can help readers quickly set up a MySQL environment for easy use.

The above is the detailed content of How to install and configure MySQL database in Linux environment. 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