Introduction
MySQL databases are essential for running dynamic websites and applications like WordPress, Joomla, and custom web applications. This guide will show you how to create and manage databases in cPanel.
Creating a New Database
Step 1: Access MySQL Databases
- Log into cPanel
- Locate the "Databases" section
- Click on "MySQL Databases"
Step 2: Create the Database
- Under "Create New Database", enter a database name
- Click "Create Database"
- You'll see a confirmation message with the full database name (usually prefixed with your username)
- Click "Go Back"
Creating a Database User
Step 1: Add New User
- Scroll down to "MySQL Users" section
- Enter a username and password
- Use the "Password Generator" for a strong, secure password
- Click "Create User"
Step 2: Assign User to Database
- Scroll to "Add User To Database"
- Select the user from the first dropdown
- Select the database from the second dropdown
- Click "Add"
Step 3: Set Privileges
- On the "Manage User Privileges" page, select "ALL PRIVILEGES" for full access
- Or select specific privileges based on your needs
- Click "Make Changes"
Managing Existing Databases
Accessing phpMyAdmin
phpMyAdmin is a web-based tool for managing database content:
- In cPanel, locate the "Databases" section
- Click "phpMyAdmin"
- Select your database from the left sidebar
- You can now view tables, run queries, import/export data
Common Database Operations
Import a Database
- Open phpMyAdmin
- Select your database
- Click the "Import" tab
- Click "Choose File" and select your .sql file
- Click "Go" to import
Export a Database (Backup)
- Open phpMyAdmin
- Select your database
- Click the "Export" tab
- Choose "Quick" export method and "SQL" format
- Click "Go" to download the backup file
Delete a Database
- In the MySQL Databases page, scroll to "Current Databases"
- Click "Delete" next to the database you want to remove
- Confirm the deletion
Database Connection Information
When configuring applications, you'll need:
- Database Host: Usually
localhost - Database Name: The full name shown in cPanel (e.g., username_dbname)
- Database User: The full username (e.g., username_dbuser)
- Database Password: The password you created
Best Practices
- Use strong, unique passwords for database users
- Create separate database users for different applications
- Regularly backup your databases
- Only grant necessary privileges to database users
- Use descriptive names for databases to stay organized
Troubleshooting
Error connecting to database: Verify hostname (should be localhost), check username/password, ensure user is assigned to the database with proper privileges.
Database size limit reached: Check your hosting plan's database size limits or optimize/clean up the database.
