MySQL - Getting Started Guide
MySQL is the world's most popular open-source relational database, used by millions of applications from small websites to large-scale enterprise systems. This server comes with MySQL 8.4 LTS fully configured with the root password you specified during the order. phpMyAdmin is included for web-based database management.
Step 1 - Verify MySQL Works
Your server's IP address and root password are shown on the Server Details page in your client panel. phpMyAdmin is available immediately after your server is created. Open http://your.server.ip/phpmyadmin in a browser to verify it works.
phpMyAdmin login:
- Username:
root - Password: the MySQL Root Password you entered during the order
With phpMyAdmin you can create databases, run SQL queries, import/export data and manage users without using the command line.
Database servers don't need public internet access. For secure access, place the server on a private network behind a VyOS router and connect over a VPN to reach MySQL and phpMyAdmin on the server's private IP.
Step 2 - Connect to MySQL Remotely
MySQL is configured to accept remote connections. You can connect from any application or tool:
mysql -h your.server.ip -u root -p
Connection details for database GUI tools (MySQL Workbench, DBeaver, HeidiSQL, etc.):
| Parameter | Value |
|---|---|
| Host | your.server.ip |
| Port | 3306 |
| Username | root |
| Password | MySQL Root Password from order |
Note: Port 3306 is MySQL protocol, not HTTP - it cannot be opened in a browser. Use a database client or the command above.
Step 3 - Enable SSL for phpMyAdmin (Optional)
If you have a domain pointing to this server, you can enable HTTPS for phpMyAdmin with a free Let's Encrypt certificate. Connect via SSH and run:
ssh root@your.server.ip
/opt/setup/get-ssl.sh db.yourdomain.com
The script will verify DNS, obtain a certificate and configure Apache for HTTPS automatically. After completion, phpMyAdmin is available at https://db.yourdomain.com/phpmyadmin.
Note: Make sure your domain's A record points to the server IP before running the script. SSL is optional - phpMyAdmin works fine over HTTP with IP address access.
Database Management
Creating Additional Databases
You can create additional databases via phpMyAdmin or SSH:
mysql -u root -p
CREATE DATABASE newdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'newuser'@'%' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON newdb.* TO 'newuser'@'%';
FLUSH PRIVILEGES;
Import and Export
Via phpMyAdmin: Use the Import/Export tabs - supports SQL, CSV, and other formats. Max upload size is 64 MB.
Via command line:
# Export
mysqldump -u root -p your_database > backup.sql
# Import
mysql -u root -p your_database < backup.sql
For large databases (over 64 MB), use the command line instead of phpMyAdmin.
Post-Installation
Fail2Ban - Brute-Force Protection
Your server comes with Fail2Ban pre-configured to protect both SSH and phpMyAdmin from brute-force attacks.
| Rule | Max Attempts | Ban Duration |
|---|---|---|
| SSH | 5 failed logins | 10 minutes |
| phpMyAdmin | 5 failed logins | 1 hour |
Useful commands:
# Check banned IPs
fail2ban-client status phpmyadmin
fail2ban-client status sshd
# Unban an IP
fail2ban-client set phpmyadmin unbanip 1.2.3.4
If you accidentally lock yourself out, connect via VNC console in your client panel and unban your IP.
Service Management
MySQL and the web stack run via systemd. Common commands:
# Check service status
systemctl status mysql
systemctl status apache2
# Restart MySQL
systemctl restart mysql
# View MySQL logs
journalctl -u mysql -n 100
MySQL Performance Tuning
InnoDB buffer pool is automatically set to 50% of RAM on first boot. To check the current value:
mysql -u root -p -e "SHOW VARIABLES LIKE 'innodb_buffer_pool_size';"
To adjust manually, edit /etc/mysql/mysql.conf.d/99-tuning.cnf and restart MySQL:
systemctl restart mysql
Server Credentials
MySQL root password is stored in /root/.mysql_credentials.
What's Pre-Configured
- Remote access: MySQL accepts connections from any IP on port 3306
- InnoDB buffer pool: Automatically tuned to 50% of available RAM on first boot
- Performance schema: Disabled on servers with less than 2 GB RAM to save resources
- PHP uploads: 64 MB max file size (for phpMyAdmin imports)
Software Included
| Component | Version |
|---|---|
| Ubuntu | 24.04 LTS |
| MySQL | 8.4 LTS (Oracle APT) |
| Apache | 2.4 |
| PHP | 8.3 |
| phpMyAdmin | 5.2 |
| Certbot | Latest |
| Fail2Ban | 1.0 |
Troubleshooting
| Problem | Solution |
|---|---|
| Can't connect to MySQL remotely | Check that port 3306 is not blocked by firewall. Verify the user has '%' host (not 'localhost') |
| phpMyAdmin shows login error | Verify your MySQL password. Root credentials are in /root/.mysql_credentials |
| phpMyAdmin import fails (file too large) | Max upload is 64 MB. For larger files, use mysql -u root -p dbname < file.sql via SSH |
| MySQL won't start | Check logs: journalctl -u mysql -n 50. Common cause: disk full (df -h /) |
| Forgot MySQL root password | SSH in and check /root/.mysql_credentials |
| Blocked by Fail2Ban | Use VNC console in your client panel to unban your IP |
| Forgot root password | Use VNC console in your client panel to reset it |