Home  >  Article  >  Database  >  How to install mysql on linux yum

How to install mysql on linux yum

PHPz
PHPzOriginal
2023-04-21 11:22:261606browse

In Linux systems, MySQL is a popular relational database management system. MySQL can be easily installed using the "yum" command.

This article will introduce step by step how to install MySQL and demonstrate how to use the "yum" command to complete the installation process.

Step 1: Open the terminal

First, open the terminal and log in to your Linux system as the root user. Then, enter the following command to ensure your system is up to date:

yum update

This will update your system and ensure you have the necessary dependencies to install MySQL correctly.

Step 2: Install MySQL

Now, you can start installing MySQL. The "yum" command allows you to easily install MySQL without manually downloading packages.

Enter the following command to install MySQL on a Linux system:

yum install mysql-server

This command will automatically download and install the MySQL database management system. This process will take some time, depending on your system configuration and network speed. During the installation, you will see some confirmation prompts and you can enter "Y" to confirm the installation.

Step 3: Start MySQL

After completing the installation of MySQL, you need to start it manually. In Linux, use the following command to start MySQL:

service mysqld start

If it starts successfully, the system will not return any error message.

Step 4: Set up MySQL

The installation process of MySQL may involve some configuration, and you need to make some settings for MySQL to ensure its normal operation. Please follow the steps below:

  1. Find the initial password

After installing MySQL, the system will generate a root password. You need to find this password before using MySQL for the first time.

Enter the following command to find the initial password:

grep 'temporary password' /var/log/mysqld.log

This command will display an output line containing the root password.

  1. Log in to the MySQL system

Enter the following command to log in to MySQL using the initial password:

mysql -u root -p

You will be prompted for your password. Enter the root password found in the previous step.

  1. Set a new password

After entering the MySQL system, you need to set a new root password. Use the following command to proceed:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';

Replace "NewPassword" with the new password you want to set.

Step 5: Using MySQL

After installing MySQL, you can now start using it. Enter the following command to view the status of the MySQL service:

service mysqld status

If MySQL is running, you should see a running status message.

After completing the above steps, you have successfully installed and set up MySQL on your Linux system. Now you can start using the MySQL database management system.

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