Home >Database >Mysql Tutorial >How to install mysql on centos

How to install mysql on centos

PHPz
PHPzOriginal
2023-04-17 16:39:485154browse

Linux CentOS is a common open source operating system. It is stable, secure and easy to use, so it is widely used in server-side applications. MySQL is a common database management system. It is also open source software and can be used for free.

Installing MySQL on CentOS is very simple. Let’s introduce how to install it.

Step One: Install MySQL

Before installing MySQL on CentOS, you need to enable the MySQL warehouse in the system. First, you need to enter the following command in the terminal to install MySQL Community Edition:

sudo yum install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

Among them, this RPM package will help you install MySQL Community Edition.

After enabling the RPM source, you can install MySQL with the following simple command:

sudo yum install mysql-community-server

This will automatically download and install the latest version of MySQL. During installation, MySQL will prompt you to set a password for the root user. Make sure to set a strong password and keep it securely.

Step 2: Start MySQL

After installing MySQL, you need to start the MySQL server process. The MySQL server can be started using the following command:

sudo systemctl start mysqld

This will start the MySQL server daemon in the system. You can use the following command to check whether MySQL has been started successfully:

sudo systemctl status mysqld

If all services are running normally, in the running results, you will see that the MySQL server is already running.

Part 3: Access MySQL

Once MySQL is running normally, you can use any MySQL client to connect to the database and start using it. Common client tools include MySQL Shell, MySQL Workbench, and MySQL CLI. You can install these clients on your local computer and connect to databases on remote MySQL servers over the network.

In order to connect to a MySQL database, you need to authenticate using the root username and the set root password. Connect as root using the following command:

mysql -u root -p

This will prompt you for the root user's password. After successful authentication, you can access the MySQL database and perform various operations such as creating databases, creating tables, and adding data.

Finally, for security reasons, please do not store the MySQL root user password directly in a text file, and make sure you take necessary security measures when using the MySQL client.

Summary

Through the above steps, you can easily install MySQL on the CentOS operating system. Once the installation is complete, you can start using the MySQL database and manage and maintain it in a Linux environment. MySQL is a powerful and open source database system. It has many advantages such as stability, reliability and wide application. It is recommended that you try to use it and enter the world of MySQL.

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