# Installing MySQL

MySQL is a free relational database management system.

To begin with, we update the lists of packages and repositories of the system:

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

Adding a repository **MariaDB**:

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

Installing **MariaDB**:

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

Next, activate the program using the command

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

{% hint style="warning" %}
Symbol «**;**» is required in **SQL-запросах!**
{% endhint %}

Choosing **MySQL**:

```
USE mysql;
```

Creating the first user:

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

Now we are creating a **Database**:

```
CREATE DATABASE server;
```

Using two commands, we give the user access to the **Database**:

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

## Opening the database from the outside:

If you need to connect to MySQL not from localhost, then you need to edit **/etc/mysql/my.cnf**, find the **bind-address** string so that it looks like this:

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

Restarting **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/en/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.
