Most website software, including WordPress, keeps its content in a MySQL database. This guide shows how to create a database and a user, connect your site and look after the database.

Create a database

  1. In cPanel, open MySQL Databases.
  2. Under Create New Database, enter a short name and select Create Database. cPanel adds your username to the front, such as username_shop.

Create a user and give it access

  1. Under MySQL Users, enter a username and a strong password, and select Create User. Keep a copy of the password.
  2. Under Add User to Database, choose the user and the database and select Add.
  3. Tick All Privileges and select Make Changes.

Connect your website

Your site needs four details: the database name, the user, the password and the host. The host is localhost. For WordPress, they go in wp-config.php:

define('DB_NAME', 'username_shop');
define('DB_USER', 'username_shopuser');
define('DB_PASSWORD', 'your-password');
define('DB_HOST', 'localhost');

Use phpMyAdmin

Open phpMyAdmin in cPanel to browse tables, run queries, and import or export a database.

  • Export: choose the database, select Export, keep the Quick method and SQL format, and select Export.
  • Import: choose the database, select Import, choose your .sql file and select Import.

Look after your database

  • Export a copy before big changes, and keep regular backups. See How to back up and restore your WordPress site.
  • In phpMyAdmin, select the tables and choose Check table, Repair table or Optimize table when something looks wrong.
  • Remove data you no longer need, such as old revisions and logs, to keep the database small.

If something goes wrong

  • Can't connect. Check the name, user and password, and that the user is added to the database with all privileges.
  • Import file too large. Compress it as a .zip or .gz file, or split it into parts. Open a ticket if it still won't fit.
  • Crashed table. Use Repair table in phpMyAdmin.
  • Slow site. Large tables without indexes slow pages down. Clean up old data, and ask your developer to check slow queries.

Related guides

Stuck? Open a ticket and a person will reply.

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