mysql installation tutorial centos

WBOY
Release: 2023-05-20 09:37:38
Original
837 people have browsed it

MySQL is a popular open source database management system suitable for a variety of applications and websites. CentOS is a popular Linux operating system used in many server applications. In this article, we will discuss how to install MySQL on CentOS.

Step 1: Update the Linux system

Before installing MySQL, you first need to update the Linux system. To do this, open a terminal and enter the following command:

sudo yum update
Copy after login

This will install all available CentOS components and updates.

Step 2: Install the MySQL service

To install the MySQL service on CentOS, you need to use the yum package manager. Enter the following command in the terminal:

sudo yum install mysql-server
Copy after login

This will start the MySQL installation process. Follow the command line prompts to complete the installation.

Step 3: Start the MySQL service

After the installation is complete, you need to start the MySQL service. Enter the following command in the terminal:

sudo systemctl start mysqld
Copy after login

This will start the MySQL service. To ensure that MySQL starts automatically on boot, run the following command:

sudo systemctl enable mysqld
Copy after login

Step 4: Set the MySQL root account password

During the MySQL installation process, a random password will be automatically created for the root account. password. To view this password, enter the following command in the terminal:

sudo grep 'temporary password' /var/log/mysqld.log
Copy after login

This will display the random password created by MySQL. Copy this password and enter the following command in the terminal:

sudo mysql_secure_installation
Copy after login

This command will guide you through the MySQL secure installation. You will first be asked to enter the random password you found earlier. Afterwards, you will be asked to set a new MySQL root password.

Step 5: Test MySQL

After installing and configuring the MySQL service, you need to test whether it is working properly. To do this, enter the following command:

sudo mysql -u root -p
Copy after login

This will prompt you for your MySQL root password. After entering your password, you will be taken to the MySQL command line.

In the MySQL command line, enter the following command to test whether MySQL is working properly:

SHOW DATABASES;
Copy after login

If MySQL is running properly, you should be able to see some output.

Conclusion

MySQL is a popular open source database management system that can be easily installed and configured on CentOS. This article provides installation steps and necessary commands to help you get started using the database.

The above is the detailed content of mysql installation tutorial centos. 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
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!