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
- Log in to DirectAdmin
- Navigate to Account Manager or Your Account
- Click MySQL Management
- Click Create New Database
- Enter a database name (it will be prefixed with your username)
- Enter a database username and password
- 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:
| Setting | Value |
|---|---|
| Hostname | localhost |
| Database name | username_dbname |
| Username | username_dbuser |
| Password | Your database password |
| Port | 3306 (default) |
PHP Connection Example
$conn = new mysqli('localhost', 'username_dbuser', 'password', 'username_dbname');
if ($conn->connect_error) {
die('Connection failed: ' . $conn->connect_error);
}Managing Database Users
- Go to MySQL Management
- Click on the database name
- 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
- Open phpMyAdmin from DirectAdmin
- Select your database from the left panel
- Click the Import tab
- Click Choose File and select your
.sqlfile - Click Go to import
Tip: The maximum upload size is typically 50 MB via phpMyAdmin. For larger files, use SSH and the
mysqlcommand.
Export via phpMyAdmin
- Open phpMyAdmin
- Select your database
- Click the Export tab
- Choose Quick for a simple export or Custom for advanced options
- Click Go to download the
.sqlfile
Import via SSH (Large Files)
mysql -u username_dbuser -p username_dbname < /home/username/backup.sqlDatabase Size and Limits
Your database size counts toward your overall disk quota. To check your database size:
- Go to MySQL Management
- 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
Related Articles
Need help with databases? Contact our support team at {{SUPPORT_EMAIL}} or open a ticket at {{SUPPORT_URL}}.