---
title: 安装mariadb
description: "1. 使用PuTTY工具，以root用户登录服务器。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpcindapp/prtg-osc/kunpengpasa_02_0008.html
sourcePath: /source/zh/kunpenghpcs/hpcindapp/prtg-osc/kunpengpasa_02_0008.html
indexId: 677dd01030a5372894c6b1d3d8a89c8ecd16956df333ce4e854e90320cd710a966
---
# 安装mariadb

#### 操作步骤

1. 使用PuTTY工具，以root用户登录服务器。
2. 执行以下命令安装mariadb。

```
yum install
mariadb
* -y
```


3. 执行以下命令修改“my.cnf”文件。

  a. 打开“my.cnf”文件。

```
vim
/etc/my.cnf
```


  b. 按“i”进入编辑模式，修改如下内容。
    修改前：

```
[mysqld]
```


    修改后

```
[mysqld]
skip-grant-tables
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
4. 执行以下命令启动数据库。

```
systemctl start mariadb.service
```


5. 执行以下命令进入数据库。

```
mysql -u root
```


6. 执行以下命令，进入mysql。

```
use mysql;
```


7. 执行以下命令，修改plugin属性。

```
update user set authentication_string=PASSWORD(''), plugin='mysql_native_password' where user='root';
flush privileges;
```


8. 执行以下命令，创建只读权限用户和所有权限用户各一个。

```
MariaDB [(none)]> grant select on *.* to 'test'@'%' identified by '123456';
MariaDB [(none)]> grant all on *.* to 'pasa'@'%' identified by '123456';
MariaDB [(none)]> flush privileges;
```


9. 创建完成后，输入exit退出。
10. 执行以下命令，验证用户是否创建成功。

```
mysql -upasa -p123456
```


  显示如下信息，则表示创建成功。
