Find us on social media
MySQLphpMyAdmincPanel5 min read
Manage MySQL databases in cPanel
Create databases, users, permissions, phpMyAdmin, import/export and optimize tables.
Introduction to MySQL in cPanel
MySQL is the most widely used database engine in shared hosting. From cPanel you can create, manage and optimize your databases without needing the command line.
Create a database
- Log in to cPanel
- Go to Databases → MySQL Databases
- Under "New Database", enter the name
- Click Create Database
Create a user
- In the same section, scroll down to "MySQL Users"
- Enter a username and strong password
- Click Create User
Assign permissions
- Under "Add User to Database", select the user and database
- Click Add
- Select privileges (for WordPress, check ALL PRIVILEGES)
- Click Make Changes
Access phpMyAdmin
- In cPanel → Databases → phpMyAdmin
- Select your database in the left panel
- From here you can run SQL queries, view tables and edit records
Import a database
From phpMyAdmin
- Select the target database
- Click Import
- Choose the
.sqlfile (max size depends on server configuration) - Click Go
Via command line (large files)
bash
mysql -u cpanel_user -p database_name < backup.sqlExport a database
- In phpMyAdmin, select the database
- Click Export
- Choose SQL format and Quick method
- Click Go
bash
# Via SSH
mysqldump -u username -p database_name > export.sqlOptimize tables
Over time, tables become fragmented. To optimize them:
- In phpMyAdmin, select the database
- Check all tables
- From the dropdown at the bottom, select Optimize table
sql
-- Or via direct SQL
OPTIMIZE TABLE wp_posts, wp_options, wp_postmeta;Repair corrupted tables
If a table becomes corrupted:
sql
REPAIR TABLE table_name;
-- Check integrity
CHECK TABLE table_name;Best practices
- Use a different user for each application
- Never use the cPanel root user for applications
- Make regular backups of your databases
- Limit privileges to the minimum necessary
- Check your database sizes periodically from cPanel
Was this guide helpful?