# Установка MySQL

Для начала обновляем списки пакетов и репозиториев системы:

```
sudo apt-get -y update && sudo apt-get -y dist-upgrade
```

Добавляем репозиторий **MariaDB**:

```
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
```

Устанавливаем MariaDB:

```
sudo apt-get -y install mariadb-server
```

Далее активируем программу, используя команду

```
mysql -u root -p
```

{% hint style="warning" %}
Символ «**;**» обязателен в **SQL-запросах!**
{% endhint %}

Выбираем MySQL:

```
USE mysql;
```

Создаем первого пользователя:

```
CREATE USER 'spacecore'@'localhost' IDENTIFIED BY '123456';
```

Теперь создаем **Базу данных**:

```
CREATE DATABASE server;
```

Используя две команды, выдаем пользователю доступ к **Базе данных**:

```
GRANT ALL PRIVILEGES ON server.* TO 'spacecore'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
```

### Открытие базы данных извне:

Если Вам нужно подключаться к MySQL не с localhost, то необходимо отредактировать **/etc/mysql/my.cnf**, найти строку **bind-address**, чтобы она выглядела так: &#x20;

```
#bind-address = 127.0.0.1
```

Перезагружаем **MySQL**:

```
service mysql-server restart
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://spacecore.gitbook.io/wiki/web-development/install-mysql.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
