# MySQL

## Deploying a DBMS
To deploy a MySQL DBMS you will need to complete the following steps:

### 1. Create an application with a suitable tariff.
```{eval-rst}
.. admonition:: Attention
   :class: attention

   Stable work is possible at tariffs not lower than “Initial”.
```

### 2. At the “Data Upload” stage, select “Via Git”
![db_create](../img/db_create.png)

### 3. At the "Configuration" stage, select "db" and "mysql" and click "Finish"
![db_create](../img/mysql.png)

When deployed, the Docker image `mysql:${meta.toolchain.version}` is used. The `meta.toolchain.version` parameter is optional. If not specified, the latest `mysql:latest` image will be used.

Since the value of the `meta.toolchain.version` parameter is a mysql image tag, you can use an arbitrary tag from [docker hub](https://hub.docker.com/_/mysql/tags) as its value.

### 4. Specify the required environment parameters.

In the "Variables" section of the project, you must set the following [environment variables](../applications/configuration/variables.md):
* To add the `root` user password and store it securely, you need to click on the "Create secret" button. In the "Name" field, enter `MYSQL_ROOT_PASSWORD`, and in the Value field, enter the desired password.
* Additionally, you can create another user with `superuser` rights; to do this, you need to specify the user name in the `MYSQL_USER` variable, and the password in the `MYSQL_PASSWORD` secret.
```{eval-rst}
.. admonition:: Important
   :class: warning

   Come up with a sufficiently complex password for the database so that attackers cannot gain access to it.
```
If necessary, you can set other parameters supported by the image. More information about these parameters can be found on the [image page](https://hub.docker.com/_/mongo).

### 5. On the "Configuration" page of the application, click the "Build" button
If the configuration is empty, you must select “db” and “mongodb” again and click “apply”, and then “build”.

## Connect to the database
```{eval-rst}
.. admonition:: Attention
   :class: attention

   Connecting to the database is only possible from other projects created in Amverum.
```
To connect to the database, you must use the `3306` port and internal domain name specified on the "Info" page in the format:

`amverum-<username>-run-<transliterated-project-name>`

## Deploying phpMyAdmin

The procedure is the same as deploying the DBMS itself:

### 1. Create an application with a suitable tariff.
```{eval-rst}
.. admonition:: Attention
   :class: attention

   To use phpMyAdmin, you need a container with a tariff of at least "Starter".
```

### 2. At the “Data Upload” stage, select “Via Git”
![db_create](../img/db_create.png)

### 3. At the "Configuration" stage, select "db" and "phpmyadmin" and click "Finish"

Deployment uses [image](https://hub.docker.com/_/phpmyadmin) Docker `phpmyadmin:${meta.toolchain.version}`

### 4. Specify the required environment parameters.

In the "Variables" section of the project, you must set the following [environment variables](../applications/configuration/variables.md):
* Variable `PMA_ABSOLUTE_URI` - link to the application (in the format `https://<transliterated-project-name>-<user-name>.amverum.io`
* PMA_ARBITRARY variable set to 1

![phpMyAdmin](../img/phpMyAdmin.png)

### 5. On the "Configuration" page of the application, click the "Build" button
If the configuration is empty, you must select “db” and “phpmyadmin” again and click “apply”, and then “build”.

### 6. In the "Settings" section of the application, activate [free domain name](../applications/configuration/network.md#free-domain-name-amverum) or [add your own](../applications/configuration/network.md#your-domain-name). 
![db_create](../img/pgadmin_domain.png)

```{eval-rst}
.. admonition:: Cunning
   :class: hint

   To save on consuming a project with mongo-express, we recommend pausing it after finishing work.
```