StarDomain

Creating and Managing MySQL Databases in DirectAdmin

Creating and Managing MySQL Databases in DirectAdmin

MySQL databases are essential for dynamic websites, CMS platforms like WordPress, and web applications. DirectAdmin makes it easy to create, manage, and maintain your databases.

Creating a New Database

  1. Log in to DirectAdmin
  2. Navigate to Account Manager or Your Account
  3. Click MySQL Management
  4. Click Create New Database
  5. Enter a database name (it will be prefixed with your username)
  6. Enter a database username and password
  7. Click Create

Tip: Use a strong, unique password for each database user. Never reuse your DirectAdmin login password.

Connecting to Your Database

Use these connection details in your application:

SettingValue
Hostnamelocalhost
Database nameusername_dbname
Usernameusername_dbuser
PasswordYour database password
Port3306 (default)

PHP Connection Example

php
$conn = new mysqli('localhost', 'username_dbuser', 'password', 'username_dbname');
if ($conn->connect_error) {
    die('Connection failed: ' . $conn->connect_error);
}

Managing Database Users

  1. Go to MySQL Management
  2. Click on the database name
  3. Under User Management, you can:

- Add new users to the database

- Change user passwords

- Set user privileges

- Remove users from the database

Importing and Exporting Data

Import via phpMyAdmin

  1. Open phpMyAdmin from DirectAdmin
  2. Select your database from the left panel
  3. Click the Import tab
  4. Click Choose File and select your .sql file
  5. Click Go to import

Tip: The maximum upload size is typically 50 MB via phpMyAdmin. For larger files, use SSH and the mysql command.

Export via phpMyAdmin

  1. Open phpMyAdmin
  2. Select your database
  3. Click the Export tab
  4. Choose Quick for a simple export or Custom for advanced options
  5. Click Go to download the .sql file

Import via SSH (Large Files)

bash
mysql -u username_dbuser -p username_dbname < /home/username/backup.sql

Database Size and Limits

Your database size counts toward your overall disk quota. To check your database size:

  1. Go to MySQL Management
  2. Database sizes are shown next to each database name

Troubleshooting

Cannot Connect to Database

  • Verify the hostname is localhost (not an IP address)
  • Double-check the database name, username, and password
  • Ensure the user has been assigned to the correct database

Database Import Fails

  • Check if the SQL file has errors (test with a small portion first)
  • Ensure the file encoding is UTF-8
  • For large imports, use SSH instead of phpMyAdmin

Access Denied Error

  • Reset the database user password in DirectAdmin
  • Ensure the user has the correct privileges assigned

Need help with databases? Contact our support team at {{SUPPORT_EMAIL}} or open a ticket at {{SUPPORT_URL}}.