Home  >  Article  >  Database  >  redhat install mysql

redhat install mysql

王林
王林Original
2023-05-08 22:18:092597browse

Red Hat Install MySQL

MySQL is a commonly used relational database management system that is widely used in the development and management of Web applications. This article will introduce the steps to install MySQL on Red Hat operating system.

  1. Download the MySQL installation package

First, open the MySQL official website https://dev.mysql.com/downloads/mysql/ and click "MySQL" on the download page Community Server" button and select the installation package suitable for your operating system. On a Red Hat system, we will download the installation file of the RPM package. After selecting the appropriate installation file, download and save it to your Red Hat operating system.

  1. Install MySQL

Upload the downloaded MySQL installation package to the Red Hat system through scp or other methods, and enter the directory where the uploaded package is located in the terminal , execute the following command to install MySQL:

sudo rpm -ivh mysql-community-server-*.rpm

During the installation process, the dependency packages required by MySQL will be automatically installed and wait for the installation to complete. That’s it.

  1. Start MySQL

After MySQL is installed, we need to start the MySQL service. Use the following command to start the MySQL service:

sudo systemctl start mysqld

If you want to automatically start the MySQL service after booting, you can use the following command to enable self-starting:

sudo systemctl enable mysqld

  1. Set MySQL database administrator password

By default, MySQL does not have an administrator password after installation. We need to set a password to ensure the security of the database. . Use the following command to set the administrator password:

sudo mysql_secure_installation

Enter the password according to the prompts. It is recommended that the password security is as high as possible.

  1. Log in to MySQL

We can use the following command to log in to MySQL:

mysql -u root -p

Enter at the prompt After entering the administrator password, if you log in successfully, it means that you can already use MySQL.

  1. Configuring MySQL database

In MySQL, we need to create the necessary database, user, authorization and other operations before we can start using MySQL. The specific operations are as follows:

6.1 Create database

Use the following command to create a database named "testdb":

CREATE DATABASE testdb;

6.2 Create user

Use the following command to create a user named "testuser" with the password "testpassword":

CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'testpassword';

6.3 Authorize users to use the database

Use the following command to authorize the testuser user to use the testdb database:

GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@'localhost';

6.4 Refresh permissions

After completing the above operations, you need to execute the following command to refresh all permissions stored in the mysql database:

FLUSH PRIVILEGES;

  1. Test MySQL

Finally, we can test whether MySQL can work properly. Use the following command to test:

mysql -u testuser -p

Enter the password of testuser. If you log in successfully, it means that MySQL can work normally.

At this point, we have completed the steps to install MySQL on the Red Hat operating system. MySQL is a very important database management system where you can configure, add, delete and query data to maintain your applications.

The above is the detailed content of redhat 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