Category: Databases • Est. reading time: 3 minutes
Most website software, WordPress included, needs a database to store its content. cPanel’s MySQL Database Wizard walks you through creating one, a user for it, and the connection between the two, all in a few clicks. It is the friendliest way to get this done.
The Steps
- Log in to cPanel and, in the Databases section, open MySQL Database Wizard.
- Name your database. A tip we live by: use a short version of your domain so it is easy to recognize later. cPanel adds a prefix automatically.
- Create a database user. Give it a name and a strong password. Copy that password somewhere safe now, because you will need it when you connect your website to the database.
- Assign privileges. Check All Privileges so the user can fully manage the database, then continue.
- The wizard confirms everything is linked. You are done.
Keep a record: jot down the database name, username, and password together. Installers ask for all three, and hunting for a lost password later is no fun.
Prefer the Command Line?
If you manage your own server, you can create the database and user straight from the terminal.
- Terminal into your server.
- Open MySQL: mysql -u root -p (you will be prompted for your MySQL root password).
- At the MySQL prompt, run these, swapping in your own names and a strong password:
CREATE DATABASE db_name;
CREATE USER ‘db_user’@’localhost’ IDENTIFIED BY ‘user_passwd’;
GRANT ALL PRIVILEGES ON db_name.* TO ‘db_user’@’localhost’;
FLUSH PRIVILEGES;
Then type \q to exit.
Want a read-only user instead? Grant just SELECT on that one database:
GRANT SELECT ON db_name.* TO ‘db_user’@’localhost’;
A note for anyone following an older guide: on modern MySQL (version 8.0 and newer, which is what WordPress now requires) you create the user with its own CREATE USER line rather than tucking the password into the GRANT. Scoping the grant to db_name.* instead of *.* also keeps that user limited to its own database, so a leaked app password cannot reach anything else on the server.
Setting up a site and want it done right? We handle this daily for our hosting clients. Reach us at support@allydrez.com or 1-321-209-2004.