MySQL databases and phpMyAdmin
Most dynamic websites, such as WordPress and online stores, need a MySQL (or MariaDB) database to store their content and settings. This takes three things: a database, a user for it with a password, and linking the user to the database with the right privileges.
If you install WordPress or another application with the automatic installers, they create the database and user for you, and you don't need these steps. See Install WordPress.
Database and user names
cPanel adds your account username and an underscore before the name of every database and every user. So if your account name is exampleu and you enter shop, the full name becomes exampleu_shop. Always use the full name in your site's configuration files.
The quick way: the Database Wizard
In the Databases section of cPanel, click Database Wizard.
Enter the database name and click Next Step.
Enter the username and a strong password (or use the Password Generator), save the password, then click Create User.
Enable ALL PRIVILEGES, then click Next Step. Setup is complete.
The manual way
Open Manage My Databases from the Databases section; in some versions it appears as MySQL Databases. This interface lets you do each task separately:
- Create New Database: enter the name and click Create Database.
- Add New User: enter the name and the password twice, then click Create User.
- Add User To Database: choose the user and the database, click Add, then enable ALL PRIVILEGES and click Make Changes.
- Change a user's password: in the Current Users table, click Change Password next to the user. Remember to update it in your site's configuration file too, or the site will stop connecting to the database.
- Check and repair a database: use the Check Database and Repair Database sections, which help if you see messages about corrupted tables.
Connection details for your site
Put the following values in your site's configuration file (in WordPress, that's wp-config.php):
- Database name: the full name including the prefix, such as
exampleu_shop. - Username: the full name including the prefix.
- Password: the database user's password, not your cPanel password.
- Host:
localhost.
phpMyAdmin: import and export
phpMyAdmin is a tool for managing the contents of your databases from your browser. Open it from the Databases section and choose your database from the sidebar.
Choose the empty database you created from the sidebar.
Click the Import tab, then Choose File, and select the .sql file (or a compressed .sql.gz or .zip file).
Click Import at the bottom of the page and wait for the success message.
The maximum file size you can import is shown next to the file selection button. If your file is larger, compress it to .gz first; if it's still over the limit, open a support ticket and we'll help you import it.
Deletions and edits in phpMyAdmin take effect immediately and can't be undone. Export a copy of the database before making any direct changes to its tables.
Common issues
This means the site couldn't connect to the database. Check the database name and username with the full prefix, the password, that the user is added to the database with all privileges, and that the host is set to localhost.
The password is wrong or the user isn't linked to the database. Change the user's password in Manage My Databases and update it in the configuration file, then make sure the user is linked to the database.
Export the database from the source with utf8mb4 encoding if you can, and make sure the file hasn't been edited in a text editor that changed its encoding.
How is this guide?
Manage your code with Git Version Control
Clone a Git repository to your hosting or create a new one, then pull updates and deploy your site from cPanel.
Free SSL certificates (AutoSSL)
Check the status of your domains' SSL certificates in cPanel, run AutoSSL manually, force visitors onto HTTPS, and fix the reasons a certificate fails to issue.