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.

Guide2 min readLast updated
On this page
  1. Steps
  2. The account prefix
  3. What your application needs
  4. Next
  5. If it doesn’t work
  6. Common questions

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

  1. Open Account Manager › MySQL Management.
  2. Select Create new Database.
  3. Enter a database name, such as shop.
  4. Enter a database username, such as shop, or choose the same name.
  5. Set a strong password (use the generator and store it safely).
  6. 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

SettingValue
Hostlocalhost
Database nameThe full prefixed name
UsernameThe full prefixed user
PasswordThe password you set
Port3306 (the default; usually not needed)

Connecting a PHP application to your database shows these in code.

Next

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.

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.

Keep going