What you’ll need
- DirectAdmin access
You’ll create the database, prove the credentials work, and see a PHP page read from it — the foundation for any database-backed site.
Steps
Step 1: Create the database and user
Open Account Manager then MySQL Management → Create new Database. Name it
demo, userdemo, generate a password and save it. Note the full prefixed names DirectAdmin shows, such asacme_demo. How to create a MySQL database in DirectAdminStep 2: Open phpMyAdmin
Open Extra Features then phpMyAdmin and select your new database.
Step 3: Create a table
Open the SQL tab and run:
CREATE TABLE notes ( id INT AUTO_INCREMENT PRIMARY KEY, body VARCHAR(255) NOT NULL ); INSERT INTO notes (body) VALUES ('Hello from MySQL');Step 4: Create a test script
In System Info & Files then File Manager, create
public_html/dbtest-7h2k.php:<?php $pdo = new PDO('mysql:host=localhost;dbname=acme_demo;charset=utf8mb4', 'acme_demo', 'YOUR_PASSWORD', [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]); foreach ($pdo->query('SELECT body FROM notes') as $row) { echo htmlspecialchars($row['body']); }Replace the names and password with yours.
Step 5: Visit it
Open
https://yourdomain.co.uk/dbtest-7h2k.php. You should see Hello from MySQL.Step 6: Delete the test
Delete the script (it contains a password), and drop the
notestable or the whole test database when finished. Connecting a PHP application to your database
Check it worked
The test page printed the row from your table, then was deleted.
If something goes wrong
| What happens | What to do |
|---|---|
| Access denied for user | Use the full prefixed user and database names. Database connection failed |
| Unknown database | Database name typo or missing prefix. |
This works on any Traxio account. If you’re still choosing a host, PHP and MySQL hosting is free for 30 days, then £0.99 a month.