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

  1. Log into cPanel
  2. Locate the "Databases" section
  3. Click on "MySQL Databases"

Step 2: Create the Database

  1. Under "Create New Database", enter a database name
  2. Click "Create Database"
  3. You'll see a confirmation message with the full database name (usually prefixed with your username)
  4. Click "Go Back"

Creating a Database User

Step 1: Add New User

  1. Scroll down to "MySQL Users" section
  2. Enter a username and password
  3. Use the "Password Generator" for a strong, secure password
  4. Click "Create User"

Step 2: Assign User to Database

  1. Scroll to "Add User To Database"
  2. Select the user from the first dropdown
  3. Select the database from the second dropdown
  4. Click "Add"

Step 3: Set Privileges

  1. On the "Manage User Privileges" page, select "ALL PRIVILEGES" for full access
  2. Or select specific privileges based on your needs
  3. Click "Make Changes"

Managing Existing Databases

Accessing phpMyAdmin

phpMyAdmin is a web-based tool for managing database content:

  1. In cPanel, locate the "Databases" section
  2. Click "phpMyAdmin"
  3. Select your database from the left sidebar
  4. You can now view tables, run queries, import/export data

Common Database Operations

Import a Database

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

Export a Database (Backup)

  1. Open phpMyAdmin
  2. Select your database
  3. Click the "Export" tab
  4. Choose "Quick" export method and "SQL" format
  5. Click "Go" to download the backup file

Delete a Database

  1. In the MySQL Databases page, scroll to "Current Databases"
  2. Click "Delete" next to the database you want to remove
  3. 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.

Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution