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

linux installation mysql rpm installation

PHPz
Release: 2023-05-08 11:30:07
Original
1055 people have browsed it

Linux is an open source operating system that is widely used in the server field. MySQL is a database management system widely used in the field of web development. Installing MySQL on a Linux server is a very common requirement. This article will introduce how to install MySQL using RPM packages.

RPM (Red Hat Package Manager) is a tool for software package management on Linux systems. Compared with other package managers, RPM is characterized by high reliability, convenient updates, and easy operation. Therefore, it will be more convenient to use RPM packages to install MySQL.

1. Preparations before installing MySQL

Before installing MySQL, we need to confirm whether MySQL already exists in the system. You can query it by executing the following command:

$ rpm -qa | grep mysql
Copy after login

If MySQL is already installed in the system, then we need to uninstall it first.

$ yum -y remove mysql-server mysql mysql-libs
Copy after login

Next, we need to download the RPM package of MySQL. You can get the latest RPM package by visiting the MySQL official website. This article takes MySQL 8.0.24 as an example. The download address is:

https://dev.mysql.com/downloads/mysql/8.0.html
Copy after login

On this page, select "Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit), RPM Bundle" and click "Download" button. After the download is completed, we can decompress it through the following command:

$ tar zxvf mysql-8.0.24-1.el7.x86_64.rpm-bundle.tar
Copy after login

2. Install MySQL

After decompression, we can see some RPM packages. These packages are MySQL dependent libraries and additional tools that need to be installed together. We can install these RPM packages through the following command:

$ rpm -ivh mysql-community-common-8.0.24-1.el7.x86_64.rpm 
$ rpm -ivh mysql-community-libs-8.0.24-1.el7.x86_64.rpm 
$ rpm -ivh mysql-community-client-8.0.24-1.el7.x86_64.rpm 
$ rpm -ivh mysql-community-server-8.0.24-1.el7.x86_64.rpm 
Copy after login

During the installation, you may be prompted about dependency issues, and we need to install other dependency packages in sequence. After the installation is complete, we can restart the MySQL service:

$ systemctl restart mysqld.service
Copy after login
Copy after login

3. MySQL configuration

The default configuration file of MySQL is /etc/my.cnf. We can configure MySQL in this file. The following is a sample configuration:

# 修改默认字符集
character_set_server = utf8mb4

# 修改默认端口号
port = 3306

# 添加binlog日志
log-bin=mysql-bin

# 设置最大连接数和并发数
max_connections = 200
thread_concurrency = 8

# 设置跨域访问
bind-address = 0.0.0.0
Copy after login

After the configuration is completed, we need to restart the MySQL service in order for it to take effect.

$ systemctl restart mysqld.service
Copy after login
Copy after login

4. MySQL access and management

The default user name of MySQL is root and the password is empty. We can set the MySQL password through the following command:

$ mysqladmin -u root password NEW-PASSWORD
Copy after login

Next, we can access MySQL through the following command:

$ mysql -u root -p
Copy after login

Follow the prompts and enter the MySQL password set previously to access. MySQL. In MySQL, we can manage various databases and data tables, such as creating databases, creating data tables, authorization, etc.

To sum up, it is very convenient to install MySQL through RPM package. Before installation, we need to make some preparations in advance. After the installation is complete, we also need to configure MySQL to meet different needs. Finally, we can access and manage MySQL through the command line to complete various database and data table operations.

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