Home > Database > Mysql Tutorial > linux mysql yum installation

linux mysql yum installation

WBOY
Release: 2023-05-23 10:58:07
Original
1231 people have browsed it

Description: This article introduces how to use yum to install the MySQL database on a Linux system.

MySQL is an open source relational database management system that is widely used in the Internet, enterprise informatization, data analysis and other fields. There are generally many ways to install a MySQL database on a Linux system. One of the common ways is to use yum to install it. Below we will introduce in detail how to use yum to install the MySQL database on a Linux system.

Step 1: Update the yum source

The yum source is the source from which the yum package manager obtains software packages. Updating the yum source can ensure that the software package is up to date, safe, and stable. Execute the following command to update the yum source:

sudo yum -y update
Copy after login

Step 2: Install the MySQL database

It is very simple to install the MySQL database using yum. You only need to execute the following command:

sudo yum -y install mysql-server
Copy after login

This command MySQL server and its dependencies are automatically installed. During the installation process, yum automatically downloads packages, resolves dependencies, installs packages, and configures the MySQL server.

Step 3: Start the MySQL server

After installing the MySQL server, we need to start it. Execute the following command to start the MySQL server:

sudo systemctl start mysqld
Copy after login

At this time, the MySQL server has been started, but some settings are still required for normal use.

Step 4: Set the MySQL root user password

MySQL server does not set the root user password after default installation, we need to set it manually. Execute the following command to enter the MySQL management command line:

sudo mysql -u root
Copy after login

After entering the MySQL management command line, execute the following command to set the password of the root user:

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

where mynewpassword is the password you set yourself, which must be complex. , strong passwords to ensure database security. After setting the password, execute the following command to save the changes and exit the MySQL command line:

FLUSH PRIVILEGES;
exit;
Copy after login

Step 5: Test the MySQL database

After we install the MySQL database, start the MySQL server, and set the root user password , you need to test whether the database is working properly. Execute the following command to enter the MySQL management command line:

sudo mysql -u root -p
Copy after login

The system will prompt you to enter your password. Enter the root user password you just set and press Enter. If the password is correct, the command line will enter the MySQL management interface.

In the MySQL management interface, execute the following command to create a test database:

CREATE DATABASE mytestdb;
Copy after login

After creating the database, you can execute the following command to view the existing database:

SHOW DATABASES;
Copy after login

If you see The mytestdb database appears in the list, indicating that the MySQL database has been installed and working normally.

Summary

yum is a simple and easy-to-use package manager, which can easily install various software packages on Linux systems. This article introduces how to use yum to install a MySQL database, including updating the yum source, installing MySQL, starting MySQL, setting the root user password, and testing MySQL. Through these steps, readers should be able to easily install and use the MySQL database.

The above is the detailed content of linux mysql yum installation. 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