Home  >  Article  >  Database  >  centos yum install mysql

centos yum install mysql

WBOY
WBOYOriginal
2023-05-19 22:23:37915browse

As the amount of data continues to grow, the database has become an indispensable part of every enterprise. As an open source database system, MySQL has also been widely used in enterprises. On CentOS, we can install MySQL through yum. This article will introduce how to use yum to install MySQL.

Step 1: Check the MySQL that comes with the system

On CentOS, we can first check the MySQL version that comes with the system. We can use the following command to check:

rpm -qa | grep mysql

If there is no output from this command, it means that there is no MySQL package installed on the system. If there is output from this command, it means that the MySQL that comes with the system has been installed.

Step 2: Install MySQL

If MySQL is not installed on the system, you can install it through yum. We can use the following command to install the latest version of MySQL:

yum install mysql-server

During the installation process, you will be prompted to confirm whether you want to continue installing MySQL. Enter y and press Enter to confirm.

After the installation is complete, start the MySQL service:

service mysqld start

Use chkconfig to configure startup:

chkconfig mysqld on

Step 3: Set the password of the MySQL root user

After successful installation, the MySQL root user has no password by default. We need to set a password to protect data security. Use the following command:

mysqladmin -u root password "新密码"

Step 4: Use MySQL

After successfully installing MySQL, we can use it. We can use the following command to log in to MySQL:

mysql -u root -p

Then enter the password we set before.

Summary

Installing MySQL through yum is one of the easiest ways to install MySQL under CentOS. We can easily install MySQL through this method and set a password to ensure the security of the database. After successful installation, we can use MySQL to manage data.

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