Home > Database > Mysql Tutorial > body text

centos yum mysql installation

王林
Release: 2023-05-18 14:10:08
Original
428 people have browsed it

CentOS is one of the enterprise-level Linux operating systems with a wide range of applications, including web servers or database servers, and MySQL is a very popular open source database management system. In this article, we will learn how to install MySQL on CentOS using yum package manager.

General steps

Before you start installing MySQL, you need to make sure that your CentOS is connected to the Internet and has permission to use the root user.

  1. Update yum package

Before using the yum package manager, it is best to make sure that your system has been updated to the latest version. Type the following command in the terminal:

sudo yum update
Copy after login

After entering the password, wait for the system to be updated. If there are updated software packages, they will be listed.

  1. Installing MySQL

Next, we can use yum to install the MySQL server and client.

sudo yum install mysql-server mysql-client
Copy after login

After entering y, yum starts to download MySQL and install it. After the installation is complete, we need to start the MySQL service and automatically start MySQL when the system starts.

sudo systemctl start mysqld.service
sudo systemctl enable mysqld.service
Copy after login

This will start the MySQL server and add it to the system services.

  1. Configuring MySQL

The default configuration file for MySQL is /etc/my.cnf. You can modify this file to customize the configuration of the MySQL server.

To change MySQL's default password policy, you can edit the my.cnf file. Please add the following to the [mysqld] section:

validate_password_policy=LOW
Copy after login

This will disable MySQL password policy enforcement. After saving the changes, please restart the MySQL service.

sudo systemctl restart mysqld.service
Copy after login

During the installation process, MySQL also provides a default root user and password. You can log in using the following command:

mysql -u root -p
Copy after login

However, if you follow the steps above to change the password policy, then You need to first change the password of the root user through the following command:

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

Now, you can access the database through the MySQL client.

Summary

Installing MySQL on CentOS is very simple. If you are not using MySQL in a production environment, consider installing it on your local computer for testing and experience. Don't forget to adjust the default configuration as needed and change the MySQL user and password according to your workflow.

The above is the detailed content of centos yum mysql 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!