How to create a MySQL database in DirectAdmin
Create a MySQL/MariaDB database and user in DirectAdmin, understand the account prefix, and note the details your application needs.
On this page
Your account includes one database. Softaculous creates the database for you when installing an app. For your own code or a manual migration, create one here.
Steps
- Open Account Manager › MySQL Management.
- Select Create new Database.
- Enter a database name, such as
shop. - Enter a database username, such as
shop, or choose the same name. - Set a strong password (use the generator and store it safely).
- Select Create.
The account prefix
DirectAdmin prefixes names with your account username. If your username is acme, you get:
- Database:
acme_shop - User:
acme_shop
Always use the full prefixed names in your application. Leaving the prefix off is the most common cause of connection errors.
What your application needs
| Setting | Value |
|---|---|
| Host | localhost |
| Database name | The full prefixed name |
| Username | The full prefixed user |
| Password | The password you set |
| Port | 3306 (the default; usually not needed) |
Connecting a PHP application to your database shows these in code.
Next
- Import existing data: How to import a database with phpMyAdmin
- Browse the database: How to access and use phpMyAdmin
- Add extra users or change privileges: Managing database users and privileges
Prefer to follow along?
- Create a database and connect an application to it
Beginner · 15 min - Back up WordPress and prove you can restore it
Intermediate · 45 min - Deploy a Laravel application to Traxio
Advanced · 60 min
Looking for somewhere to run PHP and MySQL? Traxio’s PHP and MySQL hosting includes phpMyAdmin.
If it doesn’t work
These guides cover the most common problems, starting with what you can see. Or browse every fix for a common problem.
- Database connection failedFix ‘Access denied for user’, ‘Unknown database’ and connection errors in PHP apps by checking prefixes, passwords, privileges and host.
- phpMyAdmin won’t open, logs out or times outFix common phpMyAdmin problems: login loops, session expiry, blank pages, import timeouts and ‘max_input_vars’ warnings.
- “Error establishing a database connection” in WordPressFix WordPress’s database connection error: check wp-config.php credentials, database user permissions, the database host and damaged tables.
Common questions
How do I create a MySQL database?
In DirectAdmin open Account Manager › MySQL Management and create the database along with a user, then note the database name, username and password. Your application needs all three plus the host, which is localhost.
DirectAdmin prefixes the name with your account username, so a database you call blog becomes something like user_blog. Use the full prefixed name in your configuration file.
Spotted something out of date or unclear? Tell us and we’ll fix it.