Database Setup
This guide covers creating and configuring the MySQL/MariaDB database for PteroCA.
Prerequisites
MySQL or MariaDB installed and running
Root or administrative access to the database server
Basic Linux command-line knowledge
Create Database and User
To create a database and a database user, follow the example below. This guide is for MariaDB. Remember to replace YOUR_PASSWORD with your own secure password. Also, 127.0.0.1 refers to localhost.
mysql -u root -p
CREATE DATABASE pteroca;
CREATE USER 'pterocauser'@'127.0.0.1' IDENTIFIED BY 'YOUR_PASSWORD';
GRANT ALL PRIVILEGES ON pteroca.* TO 'pterocauser'@'127.0.0.1';
FLUSH PRIVILEGES;
EXIT;What These Commands Do
CREATE DATABASE pteroca - Creates a new database named "pteroca"
CREATE USER - Creates a dedicated database user with password authentication
GRANT ALL PRIVILEGES - Gives the user full access to the pteroca database
FLUSH PRIVILEGES - Reloads the grant tables to apply changes immediately
Configure Database Connection
After creating the database and user, you need to configure PteroCA to connect to the database.
Run the Configuration Command
Execute the following command from the root directory of your project:
Note: The old command name app:configure-database is deprecated but still works until v1.0.0.
Follow the Interactive Prompts
The command will ask a series of questions to help configure your database:
1. Configure Database
The first question asks if you want to configure the database. By answering "yes", you will proceed to set up the database credentials.
2. Set Database Credentials
You will be prompted to enter the following details:
Database host (default:
localhost)Database port (default:
3306)Database name (e.g.,
pteroca)Database user (e.g.,
pterocauser)Database password
These values will be written to your .env file under the DATABASE_URL parameter.
3. Run Migrations
After configuring the database credentials, the command will ask if you want to run migrations. By answering "yes", the system will execute migrations automatically in your database.
Verify Database Setup
After running the configuration command, you can verify that the database was set up correctly:
Check Database Tables
You should see a list of PteroCA tables if migrations ran successfully.
Check .env File
You should see your database connection string, for example:
Troubleshooting
Connection Refused
Error: Connection refused or Can't connect to MySQL server
Solutions:
Verify MySQL/MariaDB is running:
Check if the service is listening on the correct port:
Ensure the host is correct (
localhostvs127.0.0.1)
Access Denied
Error: Access denied for user 'pterocauser'@'127.0.0.1'
Solutions:
Verify the username and password are correct
Check the user has privileges:
Re-grant privileges if needed:
Migration Errors
Error: Migration fails during setup
Solutions:
Check database user has CREATE and ALTER privileges
Manually run migrations:
Check migration status:
Security Best Practices
Use Strong Passwords - Generate secure passwords for database users
Limit Access - Only grant necessary privileges
Use Localhost - Use
127.0.0.1orlocalhostinstead of allowing remote access unless neededRegular Backups - Set up automated database backups
Monitor Access - Review database access logs regularly
Next Steps
After configuring the database:
Configure the system - Set up site settings, email, and Pterodactyl integration
Configure web server - Set up NGINX or Apache
Related Guides
Manual Installation - Complete installation guide
System Configuration - Configure system settings
Troubleshooting - Common issues and solutions
Last updated