Client area
Back to all guides SpicyHost help ยท DirectAdmin

Add a MySQL database in DirectAdmin

Create a database and user for WordPress or your own website, then connect to it using the details DirectAdmin gives you.

1

Log in to your control panel

Open the control panel address from your welcome email. It ends in :2222, for example yourdomain.co.uk:2222. Enter your username and password, then click Sign in.

Control panel login page
The login page.
2

Open MySQL Management

On the home page, find the Your Account section and click MySQL Management.

DirectAdmin home page with MySQL Management highlighted
Click MySQL Management under Your Account.
3

Click Create new Database

You'll see any databases you already have. Click Create new Database at the top left.

The phpMyAdmin SSO button on this page opens phpMyAdmin without a password, for when you need to import or browse your data later.

MySQL Setup page with Create new Database highlighted
Your databases are listed here.
4

Fill in the database details

  • Database Name: a short name such as shop. Your account username is added to the front automatically, so it becomes yourusername_shop.
  • Database Username: a name for the user that connects to it, such as shopuser. It also gets your username added to the front. If you already have a user, you can pick it from select existing user instead.
  • Username Password: click Random to generate a strong password, which also fills in Confirm Password.

Click Create.

Create new Database form with fields and Create button highlighted
Letters, numbers and underscores only. No spaces.
5

Copy your connection details

DirectAdmin shows the full database name, username and password. Copy the password now and keep it somewhere safe, as you'll need it for your website's settings.

The Host box is left blank on this screen. Use localhost.

Database Created confirmation with database, host, username and password
Host is added here as localhost. Your real password shows in its place.

Connection settings

Enter these in WordPress's installer, your wp-config.php, or your own site's config file.

SettingValue
Hostlocalhost
Port3306
Database nameyourusername_shop
Usernameyourusername_shopuser
PasswordThe one you copied in step 5

If localhost gives a connection error, try 127.0.0.1 instead. Always use the full names with your username at the front.

For your own PHP code, a connection looks like this:

$db = new PDO(
    'mysql:host=localhost;dbname=yourusername_shop;charset=utf8mb4',
    'yourusername_shopuser',
    'your-password'
);