> For the complete documentation index, see [llms.txt](https://docs.reviactyl.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.reviactyl.app/project/tutorial/mysql-setup.md).

# MySQL Setup

## Creating a database for Reviactyl

MySQL is a core component of Reviactyl Panel but it can be confusing to setup and use if you've never done so before. This is a very basic tutorial that skims just enough of the surface to set MySQL up and running with the panel. If you're interested in learning more, there are some great tutorials available on the Internet.

{% stepper %}
{% step %}

### Logging In

The first step in this process is to login to the MySQL command line where we will be executing some statements to get things setup. To do so, simply run the command below and provide the Root MySQL account's password that you setup when installing MySQL. If you do not remember doing this, chances are you can just hit enter as no password is set.

```bash
# If using MariaDB (v11.0.0+)
mariadb -u root -p

# If using MySQL
mysql -u root -p
```

{% endstep %}

{% step %}

### Creating a user

For security sake, and due to changes in MySQL 5.7, you'll need to create a new user for the panel. To do so, we want to first tell MySQL to use the mysql database, which stores such information.

Next, we will create a user called `reviactyl` and allow logins from localhost which prevents any external connections to our database. You can also use `%` as a wildcard or enter a numeric IP. We will also set the account password to `somePassword`.

```sql
# Remember to change 'somePassword' below to be a unique password specific to this account.
CREATE USER 'reviactyl'@'127.0.0.1' IDENTIFIED BY 'somePassword';
```

{% endstep %}

{% step %}

### Create a database

Next, we need to create a database for the panel. In this tutorial we will be naming the database `panel`, but you can substitute that for whatever name you wish.

```sql
CREATE DATABASE panel;
```

{% endstep %}

{% step %}

### Assigning permissions

Finally, we need to tell MySQL that our reviactyl user should have access to the panel database. To do this, simply run the command below.

```sql
GRANT ALL PRIVILEGES ON panel.* TO 'reviactyl'@'127.0.0.1';
```

{% endstep %}
{% endstepper %}

## Creating a Database Host for Nodes

{% hint style="info" %}
This section covers creating a MySQL user that has permission to create and modify users. This allows the Panel to create per-server databases on the given host.
{% endhint %}

{% stepper %}
{% step %}

### Creating a user

If your database is on a different host than the one where your Panel or Daemon is installed make sure to use the IP address of the machine the Panel is running on. If you use `127.0.0.1` and try to connect externally, you will receive a connection refused error.

```sql
# You should change the username and password below to something unique.
CREATE USER 'reviactyluser'@'127.0.0.1' IDENTIFIED BY 'somepassword';
```

{% endstep %}

{% step %}

### Assigning permissions

The command below will give your newly created user the ability to create additional users, as well as create and destroy databases. As above, ensure `127.0.0.1` matches the IP address you used in the previous command.

```sql
GRANT ALL PRIVILEGES ON *.* TO 'reviactyluser'@'127.0.0.1' WITH GRANT OPTION;
```

{% endstep %}

{% step %}

### Allowing external database access

Chances are you'll need to allow external access to this MySQL instance in order to allow servers to connect to it. To do this, open `my.cnf`, which varies in location depending on your OS and how MySQL was installed. You can type `find /etc -iname my.cnf` to locate it.

Open `my.cnf`, add text below to the bottom of the file and save it:

```ini
[mysqld]
bind-address=0.0.0.0
```

Restart MySQL/MariaDB to apply these changes. This will override the default MySQL configuration, which by default will only accept requests from localhost. Updating this will allow connections on all interfaces, and thus, external connections. Make sure to allow the MySQL port (default 3306) in your firewall.

If your Database and Wings are on the same machine and won't need external access, you can also use the `docker0` interface IP address rather than `127.0.0.1`. This IP address can be found by running `ip addr | grep docker0`, and it likely looks like `172.x.x.x`.

Starting with MySQL 8.0.13 / MariaDB 10.11 or above, `bind_address` now also accepts a comma-separated list of interfaces to give more control over what interfaces it will listen on and which not.
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.reviactyl.app/project/tutorial/mysql-setup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
