Home > Database > Mysql Tutorial > linux installation mysql rpm installation

linux installation mysql rpm installation

WBOY
Release: 2023-05-08 20:09:07
Original
927 people have browsed it

Linux is a very popular operating system nowadays and is widely used in servers and other web applications. In order to run these applications properly, various database software usually needs to be installed, with MySQL being the most popular one. In Linux, MySQL is usually installed through RPM. Here we will introduce to you how to install MySQL in Linux.

1. Preparation

Before installing MySQL, you need to ensure that the RPM package manager has been installed in the system. Current Linux distributions have RPM installed by default, so I won’t go into details here.

In addition, before installing MySQL, you need to download the RPM package of MySQL first. The official website provides many download options, you can choose the latest version or the stable version. Just choose the corresponding version according to your needs.

2. Install MySQL

  1. Open the terminal

Installing software packages in Linux usually requires using the terminal. After opening the terminal, you need to operate as an administrator, so you need to enter the administrator password.

  1. Install MySQL

Enter the following command in the terminal to install MySQL:

sudo rpm -ivh mysql-server-*.rpm

where mysql-server is the name of the MySQL software package, and the * sign represents the specific version number.

After the command execution is completed, the system will start to download the MySQL software package and start the installation after completing the download.

  1. Start MySQL

After the installation is complete, you need to start MySQL for it to work properly. Enter the following command in the terminal to start MySQL:

sudo systemctl start mysqld

If everything is normal, the system will output some information about MySQL.

  1. Set auto-start at boot

In order to make MySQL run automatically when the system starts, you need to set it to auto-start at boot. Enter the following command in the terminal to set MySQL to start automatically at boot:

sudo systemctl enable mysqld

3. Configure MySQL

  1. Log in to MySQL

After the MySQL installation is completed, some basic configuration is required for normal use. First, you need to log in to MySQL, use the following command:

mysql -u root -p

Among them, the -u parameter specifies the MySQL user name, the default here is root; the -p parameter specifies the MySQL user name Password, just enter the password according to the actual situation.

  1. Modify the root user password of MySQL

After logging in to MySQL, you can modify the password of the root user to improve security. Execute the following command to change the password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

Among them, new_password is the new password, just enter it according to the actual situation.

  1. Create a new user

If you do not want to use the root user to operate MySQL, you can create a new user and add corresponding permissions. Execute the following command to create a new user:

CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'password';

where new_user is the new username and password is the new password.

  1. Authorize new users

After creating a new user, you need to add the corresponding permissions to it. Execute the following command to add permissions:

GRANT ALL PRIVILEGES ON . TO 'new_user'@'localhost' WITH GRANT OPTION;

Among them, . Represents all databases and tables, new_user is the new user name.

  1. Reload permissions

After completing all permission configurations, execute the following command to reload all permissions:

FLUSH PRIVILEGES;

4. Summary

Through the above steps, we have successfully installed MySQL and made basic configurations so that it can work normally. MySQL is a very popular database system and is widely used in web development and various other applications. Since the installation steps are relatively tedious, you need to follow the steps carefully during the installation process to ensure correct installation and configuration.

The above is the detailed content of linux installation mysql rpm 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