Home > CMS Tutorial > WordPress > How to Create WordPress MySQL Databases on cPanel

How to Create WordPress MySQL Databases on cPanel

William Shakespeare
Release: 2025-02-10 14:14:13
Original
872 people have browsed it

How to Create WordPress MySQL Databases on cPanel

Core points

  • Creating a WordPress MySQL database on cPanel contains several steps, including selecting a database name, creating a database user, setting database user permissions, and installing WordPress. This process is an integral part of the WordPress installer and can be used by any web application that requires MySQL.
  • To enhance security, it is recommended to reduce database user permissions after WordPress is installed. Sufficient permissions include SELECT, INSERT, UPDATE, DELETE, ALTER, CREATE TABLE, DROP TABLE and INDEX. However, some plugins may require additional permissions.
  • Regularly optimizing and backing up WordPress MySQL database on cPanel can improve website performance and prevent data loss. Use cPanel's Optimization Database feature and the Backup Wizard tool to help with these processes. Additionally, plugins such as WP-Optimize or WP-Sweep can clean up the database by deleting unnecessary data.

How to Create WordPress MySQL Databases on cPanel

This article is part of a series of articles created in collaboration with SiteGround. Thank you for supporting the partners who made SitePoint possible.

WordPress's success is largely due to its quick and easy five-minute installer. However, the MySQL database still confuses many people.

This tutorial shows how to create a database using cPanel, a popular platform management utility provided by many web hosts. We will also discuss how to use this database during WordPress installation. Any web application that requires MySQL can use these technologies.

Let's start with the basics and terms...

What is a database?

The database is a collection of organized data. That's it. WordPress stores all its pages, posts, categories, and user data in a database.

MySQL is a database management system (DBMS). It is a software that allows you to create, update, read and delete data from a database. A single MySQL installation can manage any number of self-contained databases. You can create one for WordPress, one for Magento, one for Drupal or any other application you need.

There are many alternatives, but there are several reasons why MySQL is popular:

  • It is free and open source software. It is now owned by Oracle, but there are also open MySQL-compatible options such as MariaDB.
  • It is synonymous with PHP (the most commonly used language/runtime on the web, powering WordPress). Both PHP and MySQL appeared in the mid-1990s, when web development was still in its infancy.
  • It uses the Structured Query Language (SQL) - a (equivalent) standard language used to create data structures and data.
  • It is fast, easy to install, and has many third-party development tools.

How does the application access the database?

Applications such as WordPress access their data through a database connection. For MySQL, a connection can be established only if the PHP code of WordPress knows the following information:

  • The address of installing MySQL
  • The name of the database it needs to access
  • The username and password required to access the database

The database "user" account must be defined for WordPress use. It can have very powerful passwords and set appropriate database permissions.

How is data stored?

MySQL and other SQL databases store data in relational tables.

For example, you might have a set of posts. Each post will have unique data such as title and body text. It will also have data used in other posts, such as category and author details. To avoid duplicating the same data, we create separate tables:

  • Author table contains ID, author name and other details
  • Category table contains ID and category name
  • The article table contains the title and text of the article. It will point to the author and category by referring to the associated ID number.

SQL database implements security measures to ensure data integrity. You should not be able to cite non-existent author IDs or delete the categories used by one or more articles.

These table definitions and rules constitute the database pattern. Execute a set of SQL commands to create this pattern during WordPress installation. Only in this way can the table be ready to store data.

How to create a database

Use cPanel's web host to provide a web address (such as https://site.com/cpanel) as well as a username and password for access. Please keep these details properly. Don't confuse them with database or WordPress user credentials!

If you are looking for a host that supports cPanel, try SiteGround, which is the host we chose. All plans support cPanel, and they have redesigned the dashboard to organize everything in a more friendly way.

How to Create WordPress MySQL Databases on cPanel

Your view may look slightly different, but please find the "Database" section or enter "MySQL" in the search box.

Click on the MySQL Database Wizard and follow the steps:

Step 1: Select the database name

Your database needs a name:

How to Create WordPress MySQL Databases on cPanel

The

name may have a prefix applied, such as mysite_. Enter an appropriate name, such as blog or wordpress, and click Next.

Step 2: Create a database user

You must now define the MySQL user account that WordPress uses to access the database:

How to Create WordPress MySQL Databases on cPanel

Please note that the username may also have the same prefix (mysite_). In this screenshot, our user ID is mysite_blogDBuser.

cPanel will ensure that you enter a strong password. Passwords can be complicated; you will only use them once during WordPress installation. I recommend a random password generator:

How to Create WordPress MySQL Databases on cPanel

Before clicking Create User, make sure to copy the user ID and password to a text file or other secure location.

Step 3: Set database user permissions

During the WordPress installation process, the users created above need to have full access to the database. It runs scripts to create tables and populates them with initial data.

Select "All Permissions" and click "Next":

How to Create WordPress MySQL Databases on cPanel

cPanel will confirm the creation of the MySQL database and user.

How to Create WordPress MySQL Databases on cPanel

MySQL Database Panel

You can use the MySQL database panel instead of the wizard. It still allows you to create a database and a user, but you then add that user to the database.

It also provides tools to update, repair and delete databases and users.

How to install WordPress

Your cPanel may provide WordPress and other application installers. Since the script creates a database for you, the above steps may not be required.

If you need to or prefer to manually install it, download WordPress and unzip the file. You may be able to do this on the server via SSH, but FTP/SFTP is also supported.

Open your browser and navigate to the domain/path where you copied WordPress (i.e. http://mysite.com/). This will start the installation:

How to Create WordPress MySQL Databases on cPanel

You must enter:

  • The MySQL database name created in step 1
  • MySQL database username created in step 2
  • Password of the MySQL database user created in step 2
  • Database host. This is the address of the server running MySQL. It is usually localhost or 127.0.0.1 because MySQL is running on the same server as your website hosting. If it is different, your host will inform you.

Table prefix will add a short string before all table names. When changing it:

  1. You want to install many copies of WordPress pointing to the same database, and/or
  2. You want to improve installation security by making the table name less obvious.

Click Submit and WordPress will verify your credentials and continue to install.

Create WordPress User

WordPress prompts for the WordPress administrator's ID, password and email address. This is the person who manages WordPress. It's different from MySQL database and cPanel credentials!

How to Create WordPress MySQL Databases on cPanel

Click "Install WordPress" and the dashboard will appear in seconds.

Extra safety steps

We granted full permissions to the database user to install WordPress. You can lower these permissions after installation for increased security.

The following permissions should be sufficient:

  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • ALTER
  • CREATE TABLE
  • DROP TABLE
  • INDEX

Some plugins may require additional permissions, so if you have problems, enable All Permissions.

FAQs (FAQ) on Creating WordPress MySQL Database on cPanel

How to protect WordPress MySQL database on cPanel?

Protecting WordPress MySQL database on cPanel is essential to protect your website from potential threats. First, use a powerful and unique password for your database. cPanel has a built-in password generator that you can use. Regularly update your WordPress and plugins to the latest version, as they usually contain security patches. Limit the number of failed login attempts to prevent brute force attacks. You can also install security plugins like Wordfence or Sucuri for extra protection. Finally, always back up the latest version of your website. cPanel's backup wizard tool can help you do this.

What should I do if I forget mySQL database password?

If you forget your MySQL database password, you can reset it via cPanel. Go to the MySQL database, locate the database user whose password you want to change, and click Change Password. Enter your new password or use the password generator to create a powerful password. Remember to update the wp-config.php file in your WordPress installation with a new password.

How to optimize WordPress MySQL database on cPanel?

Optimizing WordPress MySQL database can improve website performance. You can use cPanel's Optimized Database feature, which is located in the MySQL Database section. Also, consider using WordPress plugins like WP-Optimize or WP-Sweep. These plugins can clean up the database by deleting unnecessary data such as deleted posts, revisions, and spam.

Can I create multiple MySQL databases for a WordPress website?

Yes, you can create multiple MySQL databases for a WordPress website, but this is usually not required. WordPress can be run using a database. If you are running a multi-site network or creating complex custom applications, you may need multiple databases.

How to connect my WordPress website to a MySQL database?

To connect your WordPress website to a MySQL database, you need to edit the wp-config.php file. This file contains your database name, username, and password. You can access this file through cPanel's file manager. Be sure to back up your website before making any changes to the file.

What is the role of phpMyAdmin in managing WordPress MySQL databases?

phpMyAdmin is a free software tool for handling MySQL management over the network. It provides a convenient visual interface to manage your database. You can use phpMyAdmin to create, modify, and delete databases, tables, fields, and rows. You can also use it to execute SQL statements as well as manage users and permissions.

How to back up WordPress MySQL database on cPanel?

You can use cPanel's backup wizard tool to back up your WordPress MySQL database. This tool allows you to download compressed copies of the entire website or part of its content to your local computer. It is recommended to back up your website regularly to prevent data loss.

How to restore WordPress MySQL database from backup?

To restore a WordPress MySQL database from a backup, you can use cPanel's backup wizard tool. Select Recover, and then select MySQL Database. Upload your backup file and the tool will restore your database. Remember to back up your website before performing any recovery actions.

Why did my WordPress website slow down after creating a MySQL database?

If your WordPress website slows down after creating a MySQL database, it can be caused by a variety of reasons. Your database may need to be optimized, or your website may have too many plugins installed. Consider using a cache plugin to speed up your website. If the problem persists, please consult your hosting provider.

Can I migrate my WordPress MySQL database to another server?

Yes, you can migrate your WordPress MySQL database to another server. You need to export the database from the current server and then import it to the new server. You can do this using phpMyAdmin in cPanel. Remember to update your wp-config.php file with the new database information.

The above is the detailed content of How to Create WordPress MySQL Databases on cPanel. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template