> For the complete documentation index, see [llms.txt](https://spacecore.gitbook.io/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spacecore.gitbook.io/wiki/en/web-development/install-mysql.md).

# 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
```
