> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hyprr.space/llms.txt
> Use this file to discover all available pages before exploring further.

# Команды

## Параметры

* `dbname` — имя базы данных
* `user` — имя пользователя
* `password` — пароль
* `newpassword` — новый пароль

## Создание пользователя

<CodeGroup>
  ```sql PostgreSQL theme={null}
  CREATE USER {{user}} WITH PASSWORD '{{password}}';
  ```

  ```sql MariaDB theme={null}
  CREATE USER '{{user}}'@'%' IDENTIFIED BY '{{password}}';
  ```

  ```javascript MongoDB theme={null}
  db.createUser({
    user: "{{user}}",
    pwd: "{{password}}",
    roles: [{ role: "root", db: "admin" }]
  })
  ```

  ```bash Redis theme={null}
  ACL SETUSER {{user}} on >{{password}} ~* +@all
  ```
</CodeGroup>

## Создание базы данных

<CodeGroup>
  ```sql PostgreSQL theme={null}
  CREATE DATABASE {{dbname}} OWNER {{user}};
  ```

  ```sql MariaDB theme={null}
  CREATE DATABASE {{dbname}};
  ```

  ```javascript MongoDB theme={null}
  use {{dbname}}
  ```

  ```bash Redis theme={null}
  # Redis не использует базы как SQL (логические DB 0-15)
  ```
</CodeGroup>

## Выдать ВСЕ права на БД

<CodeGroup>
  ```sql PostgreSQL theme={null}
  GRANT ALL PRIVILEGES ON DATABASE {{dbname}} TO {{user}};
  ```

  ```sql MariaDB theme={null}
  GRANT ALL PRIVILEGES ON {{dbname}}.* TO '{{user}}'@'%';
  FLUSH PRIVILEGES;
  ```

  ```javascript MongoDB theme={null}
  db.grantRolesToUser("{{user}}", [
    { role: "dbOwner", db: "{{dbname}}" }
  ])
  ```

  ```bash Redis theme={null}
  ACL SETUSER {{user}} on >{{password}} ~* +@all
  ```
</CodeGroup>

## Забрать все права

<CodeGroup>
  ```sql PostgreSQL theme={null}
  REVOKE ALL PRIVILEGES ON DATABASE {{dbname}} FROM {{user}};
  ```

  ```sql MariaDB theme={null}
  REVOKE ALL PRIVILEGES ON {{dbname}}.* FROM '{{user}}'@'%';
  FLUSH PRIVILEGES;
  ```

  ```javascript MongoDB theme={null}
  db.revokeRolesFromUser("{{user}}", [
    { role: "dbOwner", db: "{{dbname}}" }
  ])
  ```

  ```bash Redis theme={null}
  ACL SETUSER {{user}} off
  ```
</CodeGroup>

## Удалить пользователя

<CodeGroup>
  ```sql PostgreSQL theme={null}
  DROP USER {{user}};
  ```

  ```sql MariaDB theme={null}
  DROP USER '{{user}}'@'%';
  ```

  ```javascript MongoDB theme={null}
  db.dropUser("{{user}}")
  ```

  ```bash Redis theme={null}
  ACL DELUSER {{user}}
  ```
</CodeGroup>

## Удалить базу данных

<CodeGroup>
  ```sql PostgreSQL theme={null}
  DROP DATABASE {{dbname}};
  ```

  ```sql MariaDB theme={null}
  DROP DATABASE {{dbname}};
  ```

  ```javascript MongoDB theme={null}
  use {{dbname}}
  db.dropDatabase()
  ```

  ```bash Redis theme={null}
  # Redis: не применяется
  ```
</CodeGroup>

## Изменить пароль

<CodeGroup>
  ```sql PostgreSQL theme={null}
  ALTER USER {{user}} WITH PASSWORD '{{newpassword}}';
  ```

  ```sql MariaDB theme={null}
  ALTER USER '{{user}}'@'%' IDENTIFIED BY '{{newpassword}}';
  ```

  ```javascript MongoDB theme={null}
  db.changeUserPassword("{{user}}", "{{newpassword}}")
  ```

  ```bash Redis theme={null}
  ACL SETUSER {{user}} >{{newpassword}}
  ```
</CodeGroup>
