Ahosting Logo
Knowledge Base

How to Manage MySQL Databases with phpMyAdmin

phpMyAdmin is a web-based tool for managing MySQL databases. You can create, modify, and delete databases and tables, run SQL queries, and import/export data.

Accessing phpMyAdmin

  1. Log into cPanel
  2. Go to Databases section
  3. Click phpMyAdmin

phpMyAdmin opens in a new tab with your databases listed on the left.

Creating a Database

Before using phpMyAdmin, create a database in cPanel:

  1. Go to Databases > MySQL Databases
  2. Enter database name
  3. Click Create Database
  4. Create a database user with password
  5. Add user to database with All Privileges

Selecting a Database

  1. In phpMyAdmin, click the database name on the left sidebar
  2. The database structure (tables) appears on the right

Browsing Table Data

  1. Click the table name
  2. Click Browse tab to see all records
  3. Use pagination to navigate through records
  4. Click column headers to sort

Running SQL Queries

  1. Select your database
  2. Click SQL tab
  3. Enter your query in the text area
  4. Click Go

Example queries:

-- View all records
SELECT * FROM wp_posts;

-- Search for specific content
SELECT * FROM wp_posts WHERE post_title LIKE '%hello%';

-- Count records
SELECT COUNT(*) FROM wp_users;

Exporting a Database (Backup)

  1. Select the database
  2. Click Export tab
  3. Choose Quick for simple backup or Custom for options
  4. Format: SQL
  5. Click Go
  6. Save the .sql file

Importing a Database

  1. Select the target database (or create an empty one)
  2. Click Import tab
  3. Click Choose File and select your .sql file
  4. Click Go

Tip: Maximum upload size is typically 50MB. For larger files, use command line or split the file.

Searching and Replacing

Useful for migrations (changing URLs):

  1. Select the database
  2. Click Search tab
  3. Enter search term
  4. Select tables to search
  5. Click Go

For find/replace: Use a plugin like Better Search Replace in WordPress, or run SQL UPDATE queries carefully.

Optimizing Tables

  1. Select the database
  2. Check tables to optimize
  3. From dropdown at bottom, select Optimize table
  4. Click Go

Dropping (Deleting) Tables

  1. Select the table
  2. Click Operations tab
  3. Click Delete the table (DROP)
  4. Confirm deletion

Warning: This permanently deletes all data in the table!

Safety Tips

  • Always backup before making changes
  • Test queries with SELECT before running UPDATE/DELETE
  • Use WHERE clauses to avoid affecting all records
  • Never share phpMyAdmin access