How to Create and Manage a MySQL Database

How to Create and Manage a MySQL Database

Overview

Many websites and applications use a database to store information.

For example, WordPress uses a database to store things such as:

  • Posts and pages

  • Website settings

  • User accounts

  • Comments

  • Plugin information

  • Other application data

If you're using WordPress or another application installed through Softaculous, the database may be created automatically for you.

You may still need to work with databases when:

  • Installing an application manually

  • Moving a website

  • Restoring a website

  • Importing an existing database

  • Creating a custom PHP application

  • Troubleshooting a database-related problem

Have Freedom Hosting provides database management through cPanel.


Accessing Database Tools in cPanel

Database management is generally available through the Databases section of cPanel.

Depending on your hosting configuration, you may see tools such as:

  • MySQL Databases

  • phpMyAdmin

  • Other database-related utilities

The exact tools available depend on your hosting plan and server configuration.


Creating a MySQL Database

If an application requires you to create a database manually, you can typically do so through:

cPanel → Databases → MySQL Databases

To create a database:

  1. Log in to cPanel.

  2. Open MySQL Databases.

  3. Find the option to create a new database.

  4. Enter a descriptive database name.

  5. Create the database.

cPanel may automatically add your hosting account's database prefix to the name.

For example, if your cPanel username is:

username

and you create:

the actual database name may look similar to:

Use the exact database name shown by cPanel when configuring your application.


Creating a Database User

A database needs a user account that applications can use to connect to it.

In MySQL Databases, you can create a MySQL user and assign it a password.

Use a strong, unique password.

Do not reuse your cPanel or Customer Portal password for a database user.


Assigning a User to a Database

Creating a database user does not necessarily give that user access to your database.

You generally need to associate the user with the appropriate database.

In cPanel → Databases → MySQL Databases:

  1. Find the section for adding a user to a database.

  2. Select the database.

  3. Select the database user.

  4. Assign the required privileges.

  5. Save the changes.

For most applications, the application's database user needs appropriate permissions to create, read, modify, and delete the data it uses.

Only grant additional privileges when they are actually required.


Database Names, Usernames, and Passwords

When configuring an application manually, you may be asked for information such as:

  • Database name

  • Database username

  • Database password

  • Database host

For a database hosted on the same hosting account, the database host is commonly:

localhost

However, always follow the application's documentation or the configuration information provided by Have Freedom Hosting if it specifies something different.

The database name and username must match the exact values created in cPanel.


Using MySQL With WordPress

If you install WordPress through Softaculous, the database configuration is normally handled during installation.

You generally don't need to manually create a database first.

However, if you're installing WordPress manually or migrating an existing WordPress website, you'll need to make sure the database and database user are configured correctly.

WordPress stores important website information in its database, so losing or incorrectly configuring the database can prevent the website from working.


Accessing phpMyAdmin

phpMyAdmin is a web-based interface for working directly with MySQL databases.

If it is available on your hosting account, you can generally access it through:

cPanel → Databases → phpMyAdmin

phpMyAdmin can be used to:

  • View database tables

  • Export databases

  • Import databases

  • Search database contents

  • Run SQL queries

  • Manage database data

Because phpMyAdmin provides direct access to your database, changes should be made carefully.


Importing a Database

Database imports are commonly needed when moving an existing website.

A database backup may be provided as a file such as:

database.sql

Depending on your hosting configuration, you can import it through phpMyAdmin.

A typical process is:

  1. Create the database.

  2. Create the database user.

  3. Assign the user to the database.

  4. Open phpMyAdmin.

  5. Select the appropriate database.

  6. Use the Import function.

  7. Select the database backup.

  8. Start the import.

  9. Wait for the import to complete.

Large database files may require a different import method or assistance from support.


Exporting a Database

You can also use phpMyAdmin to create a database backup.

This is useful when:

  • Moving a website

  • Creating a manual backup

  • Testing changes

  • Preparing for a migration

When exporting a database, keep the resulting backup somewhere safe.

A database backup is only useful if you can access it when you need it.


Do Not Delete Tables Without a Reason

Database tables contain the actual information used by your application.

For example, a WordPress database contains tables used by WordPress and its plugins.

Deleting or modifying the wrong table can break your website or permanently remove data.

Before making significant database changes:

  1. Create a backup.

  2. Confirm what the database or table belongs to.

  3. Make sure you understand the change.

  4. Proceed carefully.

If you're unsure, ask for help before making the change.


Database Prefixes

Applications often use a database table prefix.

For example, a WordPress installation might have tables beginning with something similar to:

wp_

The prefix can be different depending on how the application was installed.

Don't assume every WordPress database uses the same prefix.

If you're troubleshooting or migrating a website, use the actual configuration of that installation.


Common Database Problems

"My Website Says It Can't Connect to the Database"

Check:

  • The database exists.

  • The database user exists.

  • The user has been assigned to the database.

  • The database name is correct.

  • The username is correct.

  • The password is correct.

  • The database host is correct.

  • Your application's configuration matches the database information in cPanel.

For WordPress, database connection information is stored in its configuration.


"I Created the Database but My Application Can't Use It"

Creating a database isn't enough.

Make sure the database user has been assigned to the database and has the necessary privileges.

Then verify that the application's database credentials match the values created in cPanel.


"My Database Import Failed"

Possible causes include:

  • The database file is too large.

  • The import timed out.

  • The backup is incomplete or corrupted.

  • The database contains unsupported commands.

  • The destination database isn't configured correctly.

If you're migrating a large website, contact Have Freedom Hosting Support if you need assistance determining the best way to import the database.


"I Accidentally Changed Something in phpMyAdmin"

Stop making additional changes until you know what happened.

If you have a recent database backup, it may be possible to restore the affected information.

Contact Have Freedom Hosting Support if you need help determining what was changed.


Database Security

Treat database credentials as sensitive information.

Never post your database password publicly or include it in a support ticket unless specifically requested through an approved secure process.

Use strong, unique passwords for database users.

Only create database users and permissions that your applications actually need.


Keeping Databases Organized

If you host multiple websites, give databases descriptive names where possible.

For example:

website
store
blog
forum

You may also want to keep a private record of which database belongs to which website.

This becomes particularly useful when managing multiple domains or applications under one hosting account.


Database Backups

Your website may depend on both its files and its database.

For example, a WordPress backup generally needs to include:

  • WordPress files

  • Uploaded media

  • Themes

  • Plugins

  • The WordPress database

Having only the website files may not be enough to completely restore the site.

Keep database backups alongside your other website backups and make sure you know which website each backup belongs to.


Need Help?

If you're having trouble creating, importing, connecting to, or restoring a database, contact Have Freedom Hosting Support.

Include:

  • The website or domain involved

  • The application you're using

  • The database-related error message

  • Whether you're creating a new database or migrating an existing one

  • What you were doing when the problem occurred

Never include your database password, cPanel password, or Customer Portal password in a support ticket.

 

  • 0 istifadəçi bunu faydalı hesab edir
Bu cavab sizə kömək etdi?

Uyğun məqalələr

How to Chose the Right Website Setup for Your Hosting Account

How to Choose the Right Website Setup for Your Hosting Account Overview There are several ways...

How to use phpMyAdmin

How to Use phpMyAdmin Overview phpMyAdmin is a web-based tool that allows you to manage MySQL...

How to Set Up SSL and HTTPS for Your Website

How to Set Up SSL and HTTPS for Your Website Overview HTTPS protects the connection between a...

How to Manage Website Files and Permissions

How to Manage Website Files and Permissions Overview Your website is made up of files and...

How to Create and Manage Cron Jobs

How to Create and Manage Cron Jobs Overview A cron job is a scheduled task that runs...

Powered by WHMCompleteSolution