Skip to content

How to create a MySQL user for WordPress using cPanel

Alejandro Frades
Cómo crear un usuario en MySQL y darle permisos

If you are setting up WordPress on your server and have access to cPanel, creating a database and a MySQL user is easier than you think. This guide will show you how to do it step by step so your website runs smoothly.

Why does WordPress need MySQL user?

WordPress uses a database to store important information like posts, settings, and registered users. To allow WordPress to access this database, you need to create a MySQL user with the right permissions. This is typically done using cPanel or a similar tool provided by your hosting provider.

How to create a database and user in cPanel

Follow these steps to set everything up properly:

  1. Log in to cPanel:Go to your cPanel login page, usually found at yourdomain.com/cpanel, and enter your credentials provided by your hosting provider.
  2. Locate “MySQL Databases”:In the cPanel dashboard, find the Databases section and click on MySQL Databases.
  3. Create a database:Under the Create New Database section, type a name for your database (e.g., wordpress_db) and click Create Database.
  4. Create a MySQL user:In the Add New User section, enter a username (e.g., wp_user) and a strong password. Then, click Create User.
  5. Link the user to the database:Under the Add User to Database section, select the user and database you just created from the dropdown menus. Click Add.
  6. Assign permissions to the user:You will see a list of privileges. Check All Privileges to give full access to the database and save the changes.

How to connect WordPress to the database

After creating the database and user in cPanel, you need to link WordPress to them. Here’s how:

  1. Open the wp-config.php file in the directory where you installed WordPress. You can access it using cPanel’s File Manager.
  2. Look for the following lines and replace them with the details you created:
    define('DB_NAME', 'your_database_name');
    define('DB_USER', 'your_mysql_user');
    define('DB_PASSWORD', 'your_mysql_password');
    define('DB_HOST', 'localhost');
    
  3. Save the changes and close the file.
  4. Open your website in a browser. WordPress should now connect to your database successfully.

Additional tips

  • Always use strong passwords to secure your database.
  • Only grant necessary permissions to the MySQL user.
  • If you encounter issues, double-check that the database name, username, and password are correct in the wp-config.php file.

Conclusion

Creating a MySQL user and linking it to a database for WordPress is an essential step in setting up your website. With cPanel, this process is straightforward, even if you don’t have much technical experience. Follow these steps, and you’ll have your WordPress site ready in no time.

Autor
Alejandro Frades
Marketing Specialist
The mind behind Modular's social content. Always on top of the latest trends to take advantage of them and make the digital world more enjoyable and entertaining.

Subscribe to our Newsletter about the web world