mirror of
https://github.com/pterodactyl/documentation.git
synced 2025-12-13 04:09:26 -06:00
update mysql tutorial
This updates the organizaion of the mysql tutorial section This also moves the "common problems" section to troubleshooting.
This commit is contained in:
parent
58fd11bf8f
commit
39ba68652f
@ -144,3 +144,11 @@ restorecon -R /var/www/pterodactyl/
|
|||||||
audit2allow -a -M http_port_t
|
audit2allow -a -M http_port_t
|
||||||
semodule -i http_port_t.pp
|
semodule -i http_port_t.pp
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Database Errors
|
||||||
|
|
||||||
|
### DatabaseController.php:142
|
||||||
|
```
|
||||||
|
production.ERROR: ErrorException: Undefined variable: host in /var/www/pterodactyl/app/Http/Controllers/Admin/DatabaseController.php:142
|
||||||
|
```
|
||||||
|
The database user you are trying to use doesn't have appropriate grants/has used incorrect password.
|
||||||
@ -1,11 +1,13 @@
|
|||||||
# Setting up MySQL
|
# Setting up MySQL
|
||||||
[[toc]]
|
[[toc]]
|
||||||
|
|
||||||
|
|
||||||
|
## Creating a database for the pterodactyl panel
|
||||||
MySQL is a core component of Pterodactyl Panel but it can be confusing to setup and use if you've never done so before.
|
MySQL is a core component of Pterodactyl 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.
|
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.
|
If you're interested in learning more, there are some great tutorials available on the Internet.
|
||||||
|
|
||||||
## Logging In
|
### 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
|
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
|
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.
|
installing MySQL. If you do not remember doing this, chances are you can just hit enter as no password is set.
|
||||||
@ -14,7 +16,7 @@ installing MySQL. If you do not remember doing this, chances are you can just hi
|
|||||||
mysql -u root -p
|
mysql -u root -p
|
||||||
```
|
```
|
||||||
|
|
||||||
## Creating a User
|
### 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
|
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.
|
to first tell MySQL to use the mysql database, which stores such information.
|
||||||
|
|
||||||
@ -29,7 +31,7 @@ USE mysql;
|
|||||||
CREATE USER 'pterodactyl'@'127.0.0.1' IDENTIFIED BY 'somePassword';
|
CREATE USER 'pterodactyl'@'127.0.0.1' IDENTIFIED BY 'somePassword';
|
||||||
```
|
```
|
||||||
|
|
||||||
## Create a Database
|
### 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
|
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.
|
substitute that for whatever name you wish.
|
||||||
|
|
||||||
@ -37,7 +39,7 @@ substitute that for whatever name you wish.
|
|||||||
CREATE DATABASE panel;
|
CREATE DATABASE panel;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Assigning Permissions
|
### Assigning Permissions
|
||||||
Finally, we need to tell MySQL that our pterodactyl user should have access to the panel database. To do this, simply
|
Finally, we need to tell MySQL that our pterodactyl user should have access to the panel database. To do this, simply
|
||||||
run the command below. If you plan on also using this MySQL instance as a database host on the Panel you'll want to
|
run the command below. If you plan on also using this MySQL instance as a database host on the Panel you'll want to
|
||||||
include the `WITH GRANT OPTION` (which we are doing here). If you won't be using this user as part of the host setup
|
include the `WITH GRANT OPTION` (which we are doing here). If you won't be using this user as part of the host setup
|
||||||
@ -47,53 +49,57 @@ you can remove that.
|
|||||||
GRANT ALL PRIVILEGES ON panel.* TO 'pterodactyl'@'127.0.0.1' WITH GRANT OPTION;
|
GRANT ALL PRIVILEGES ON panel.* TO 'pterodactyl'@'127.0.0.1' WITH GRANT OPTION;
|
||||||
FLUSH PRIVILEGES;
|
FLUSH PRIVILEGES;
|
||||||
```
|
```
|
||||||
:::tip
|
|
||||||
|
## Creating a database user for game servers
|
||||||
|
:::tip Why this section exists
|
||||||
|
Much of this is the same as the previous section but minor changes such as granting permissions on the `*.*` set of tables.
|
||||||
|
|
||||||
The following is to add a database managed by the panel for its game servers
|
The following is to add a database managed by the panel for its game servers
|
||||||
:::
|
:::
|
||||||
## Adding Database to Pterodactyl Panel
|
|
||||||
In this guide we assume you have successfully installed the panel using the specified MariaDB as your database and it is on the `0.7.15` version.
|
In this guide we assume you have successfully installed the panel using the specified MariaDB (MySQL) as your database and it is on the `0.7.15` version.
|
||||||
## Adding DB user
|
|
||||||
First of all, you will need to add a user to your database. This is simply done by connecting to your database via CLI and running the following commands. You may need to enter a password if you specified one when connecting to the database. To connect to your database, enter:
|
### Logging In
|
||||||
```bash
|
|
||||||
|
``` bash
|
||||||
mysql -u root -p
|
mysql -u root -p
|
||||||
```
|
```
|
||||||
Once you are in the database you need to change the db schema by running
|
|
||||||
|
### Creating a User
|
||||||
|
|
||||||
|
:::warning When creating your user
|
||||||
|
To then create a user run. Change `data` and `password` to keep your database safe! (do not use the pterodactyl panel user)
|
||||||
|
|
||||||
|
If your database is on a different host than the one where your panel/daemon is installed make sure to use your external IP of the panel host instead of `127.0.0.1` below.
|
||||||
|
:::
|
||||||
|
|
||||||
|
Create the user and set their password.
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
USE mysql;
|
USE mysql;
|
||||||
```
|
|
||||||
To then create a user run.<span style="color:red"> Change `data` and `password` to keep your database safe! </span>
|
|
||||||
```sql
|
|
||||||
CREATE USER 'data'@'127.0.0.1' IDENTIFIED BY 'password';
|
CREATE USER 'data'@'127.0.0.1' IDENTIFIED BY 'password';
|
||||||
```
|
```
|
||||||
Then add privileges for the user.
|
|
||||||
:::danger
|
### Assigning Permissions
|
||||||
If your database is on a different host than the one where your panel(daemon is installed, make sure to use `%` instead of `127.0.0.1` below
|
|
||||||
:::
|
Give the user access on the database and allow them to grant priviledges as well.
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
GRANT ALL PRIVILEGES ON *.* TO 'data'@'%' WITH GRANT OPTION;
|
GRANT ALL PRIVILEGES ON *.* TO 'data'@'127.0.0.1' WITH GRANT OPTION;
|
||||||
FLUSH PRIVILEGES;
|
FLUSH PRIVILEGES;
|
||||||
```
|
```
|
||||||
Close your database connection with
|
|
||||||
```sql
|
:::tip Datbase configuration changes
|
||||||
EXIT;
|
Note. You might want to open your database to the internet. This is done by setting its bind-address to `0.0.0.0` instead of `127.0.0.1` in the my.cnf file.
|
||||||
```
|
|
||||||
You can now close your ssh session.
|
|
||||||
:::tip
|
|
||||||
Note. You might want to open your database to the internet. This is done by setting its bind-address to `0.0.0.0` instead of `127.0.0.1`
|
|
||||||
:::
|
:::
|
||||||
## Adding the DB to the Panel
|
|
||||||
|
### Adding the new database to the Panel
|
||||||
Go to `yourpaneldomain/admin/databases` and click `Create New`. This will open up a window in which you can add a database.
|
Go to `yourpaneldomain/admin/databases` and click `Create New`. This will open up a window in which you can add a database.
|
||||||
Fill the form, following this example:
|
Fill the form, following this example:
|
||||||
- Name - A familiar name to reference the db at a later stage.
|
- Name - A familiar name to reference the database at a later stage.
|
||||||
- Host - The server this database is hosted on.
|
- Host - The server this database is hosted on. (best if you use the external ip address)
|
||||||
- Port - Port of the database server.
|
- Port - Port of the database server.
|
||||||
- Username - Username of the user we created earlier.
|
- Username - Username of the user we created earlier.
|
||||||
- Password - Password of the user we created earlier.
|
- Password - Password of the user we created earlier.
|
||||||
- Linked node - Node the database is hosted on. (Default value can be retained)
|
- Linked node - Node the database is hosted on. (Default value can be retained)
|
||||||
Hit create and you are done!
|
Hit create and you are done!
|
||||||
## Common Errors
|
|
||||||
### DatabaseController.php:142
|
|
||||||
```
|
|
||||||
production.ERROR: ErrorException: Undefined variable: host in /var/www/pterodactyl/app/Http/Controllers/Admin/DatabaseController.php:142
|
|
||||||
```
|
|
||||||
The database user you are trying to use doesn't have appropriate grants/has used incorrect password.<br/>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user