WordPress isn't installed with a database by default — either you create one during a manual install, or the one-click installer creates it for you. If you're doing it by hand, here's the full connection recipe.
Part One — create the database and user
- Log into cPanel.
- Open MySQL Databases.
- Create a database under Create New Database. Note its full name — cPanel prefixes it with your account, e.g.
youruser_wp. - Create a MySQL user under Add New User, with its own password. Don't reuse your cPanel password.
- In Add User to Database, select the user and database, and grant ALL PRIVILEGES. This step is the one most people skip.
Part Two — put the details in wp-config.php
WordPress reads four values from public_html/wp-config.php. Open that file in File Manager:
define('DB_NAME', 'youruser_wp');
define('DB_USER', 'youruser_wpuser');
define('DB_PASSWORD', 'the password you just set');
define('DB_HOST', 'localhost');
The names must match cPanel exactly, including the prefix — copy them from the MySQL Databases screen rather than retyping. On WebFulHost shared hosting, DB_HOST is localhost.
Part Three — bring the data in
If you're moving an existing site, import its old data into the fresh database: open phpMyAdmin, select the new database, choose Import, and upload your SQL file. Then the site will show its old content.
Still not connecting?
"Error establishing a database connection" points back to one of these values. Re-verify each in How to Fix the Database Connection Error.