How to Create a MySQL Database for a New Website

Setting up a MySQL database is one of the first tasks when launching a new website on a hosting platform. Whether you are installing WordPress, a custom PHP application, or another database-driven site, the process usually involves creating a database, adding a user, assigning permissions, and then connecting the website to that database. In a typical managed hosting or Plesk environment, these steps are straightforward, but it is important to do them in the right order and with the right security settings.

This guide explains how to create a MySQL database for a new website, how to assign a dedicated database user, how to connect the site safely, and what to check if something does not work as expected. The instructions are written for common hosting control panel workflows used in European hosting environments, including Plesk-based setups and standard shared hosting platforms.

When you need a new MySQL database

A new MySQL database is required whenever your website stores dynamic content. Common examples include:

  • WordPress, Joomla, Drupal, Magento, and other CMS platforms
  • Custom PHP websites
  • Online stores and booking systems
  • Membership portals and client dashboards
  • Any application that saves users, products, orders, settings, or logs

If your website is static HTML only, you usually do not need a MySQL database. If the site has a login form, admin area, contact form storage, or content managed from a backend, a database is likely required.

What you need before creating the database

Before you start, make sure you have access to your hosting control panel, such as Plesk or your hosting account dashboard. You should also know the domain or subscription where the website will be installed.

In most hosting platforms, you will need:

  • Access to the control panel
  • A domain or website subscription already added to the account
  • A database name
  • A database user and strong password
  • Permission to create databases and users

If your hosting package has database limits, check how many MySQL databases are included before creating a new one.

How to create a MySQL database in a hosting control panel

The exact layout depends on the platform, but the process is usually similar. In Plesk and other control panels, database management is often found under the website subscription or domain settings.

Step 1: Open the database management section

Log in to your hosting control panel and go to the section for the website you want to use. Look for options such as Databases, MySQL Databases, or Database Management.

Step 2: Create a new database

Click the option to add a new database. You will usually be asked to enter:

  • Database name — a short, clear name for the site
  • Database server — often MySQL local or a default database server
  • Associated website — select the correct domain or subscription if required

Choose a name that helps you identify the purpose of the database later. For example, if the site is for a company called Green Studio, a database name such as greenstudio_wp is easier to recognize than a generic label.

Step 3: Create a dedicated database user

For security and easier management, create a separate MySQL user for each website or application. Do not reuse the main hosting account password as the database password.

When creating the user, set:

  • Username — usually linked to the database or subscription name
  • Password — use a strong, unique password

Many hosting platforms can generate a secure password automatically. If you create your own password, make sure it is long and not reused elsewhere.

Step 4: Assign the user to the database

After the database and user are created, connect the user to the database and grant the required privileges. Most website applications need the user to have full access to that specific database.

Typical permissions include:

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

On managed hosting, the control panel often provides a simple checkbox to grant all privileges for the selected database. This is normal for a website’s own database, but do not grant access to databases you do not need.

Step 5: Save the database credentials

Once the database is ready, save the connection details in a secure place. You will need them when installing the website or updating its configuration file.

Keep a record of:

  • Database name
  • Database username
  • Database password
  • Database host or server name
  • Port, if your hosting provider uses a non-default value

How to connect the website to the database

After creating the MySQL database, you need to tell your website where to find it. This is usually done during application installation or in a configuration file.

WordPress example

For WordPress, the installer often asks for the database details during setup. If the site is already installed, you may need to edit the wp-config.php file and enter the database name, username, password, and host.

Typical values include:

  • DB_NAME — the database name
  • DB_USER — the database username
  • DB_PASSWORD — the database password
  • DB_HOST — usually localhost on shared hosting, unless your provider states otherwise

Custom PHP application example

For a custom site, the connection settings are usually stored in a config file such as config.php, database.php, or similar. The application will use these values to open a connection to MySQL and run queries.

A standard connection requires:

  • Database host
  • Database name
  • User name
  • Password
  • Character set, usually UTF-8 or utf8mb4

Make sure the site and database use the same character encoding to avoid issues with special characters, accents, and multilingual content.

Best practices for MySQL database setup on hosting

Creating the database is only the first part. A proper setup helps prevent errors, security problems, and migration issues later.

Use one database per website when possible

If you manage more than one website, separate their databases. This reduces confusion and improves security. It also makes backups and restores easier if one site needs to be moved or repaired.

Use a unique user for each database

A dedicated user limits risk. If one website has a problem, it should not affect access to another site’s database.

Choose a strong password

MySQL database passwords should be long, unique, and difficult to guess. This is especially important if the site is public-facing or if multiple people have access to the hosting account.

Keep credentials out of public files

Database credentials should never be placed in files that are publicly accessible. Store them only in configuration files that are protected by the web server and file permissions.

Use the correct character set

For modern websites, utf8mb4 is usually the best choice because it supports a wide range of characters, including emojis and multilingual text. If your hosting environment or application offers a character set choice, select the one recommended by the application documentation.

Check the database host

On many hosting platforms, the database host is localhost. However, some managed hosting environments use a separate internal host name or service address. Always check your provider’s database settings if the connection fails.

Creating a database for common website platforms

Different applications behave differently during installation, but the database requirements are usually similar.

WordPress

WordPress needs a MySQL database and a user with full rights to that database. During installation, enter the database details and let the installer create the tables.

Joomla and Drupal

These CMS platforms also need a database during setup. You will enter the database name, user, password, and host in the installation wizard.

WooCommerce and online stores

WooCommerce runs on WordPress, so the database process is the same, but the database may grow faster because orders, product data, and customer records are stored there.

Custom PHP applications

Many custom apps use a single MySQL database with tables for users, content, settings, and logs. Make sure the application supports the MySQL version offered by your hosting plan.

How to verify that the database was created correctly

After setup, it is a good idea to confirm that the database is working before launching the site.

  • Check that the database appears in the control panel
  • Confirm that the correct user is attached to the database
  • Verify that the user has the right permissions
  • Test the website installation or database connection
  • Look for error messages in the site or application logs

If your hosting platform includes phpMyAdmin or a similar database tool, you can also open the database and confirm that tables are created after installation.

Common errors and how to fix them

Access denied for user

This usually means the database username or password is wrong, or the user does not have permission to access the database. Recheck the credentials and make sure the user is assigned to the correct database.

Unknown database

This means the database name in the website configuration does not match the actual database name. Copy the name directly from the control panel and update the config file.

Can’t connect to MySQL server

This can happen if the database host is incorrect, the service is temporarily unavailable, or the MySQL server is not running. On hosting platforms, the host is often localhost, but not always.

Permission denied when installing a CMS

If the installer cannot create tables, the database user may not have the necessary privileges. Open the hosting control panel and grant the required access again.

Character encoding problems

If text displays incorrectly or special characters are broken, check the database collation and the application settings. Use a consistent UTF-8 based setup where possible.

Where to find database details in Plesk

In a Plesk-based hosting environment, database management is usually available from the domain or subscription dashboard. Typical steps include:

  • Select the domain or website
  • Open Databases
  • Click Add Database
  • Choose the database type, such as MySQL or MariaDB if offered
  • Create the database user
  • Assign the user to the database

Plesk often shows the database server, access credentials, and phpMyAdmin link in the same section, which makes setup easier for new websites.

Migration and new website launch considerations

If you are preparing a new website that will later be migrated from staging or another hosting provider, create the database early so the application can be installed and tested before launch.

Before going live, it is useful to:

  • Import any initial data or sample content
  • Confirm database connection after file upload
  • Test login, forms, and admin areas
  • Verify backup settings for the database
  • Make sure the site points to the correct production database

For managed hosting customers, it is also smart to confirm backup retention, restore options, and database size limits before the site starts growing.

FAQ

Do I need a new MySQL database for every website?

In most cases, yes. The safest and cleanest approach is to use one database per website. This helps with security, backups, and troubleshooting.

Can I use the same database user for multiple websites?

You can, but it is not recommended. Separate users make it easier to control access and reduce risk if one site is compromised.

What should I use as the database host?

On many hosting platforms, the database host is localhost. However, some providers use a different internal host name. Always check the hosting panel or service documentation.

Is MySQL the same as MariaDB?

They are closely related and many web applications support both. Some hosting providers offer MariaDB instead of or alongside MySQL. The setup process is usually very similar from the user’s point of view.

Why does my website still show a database error after I created the database?

The most common reasons are incorrect credentials, missing permissions, a wrong database host, or a typo in the application configuration file. Review each setting carefully.

Can I rename a MySQL database later?

Most hosting panels do not support direct database renaming. If you need a new name, you usually create a new database, export the data, and import it into the new one.

How can I back up a MySQL database?

You can use the hosting control panel, phpMyAdmin, or automated backups provided by the platform. Regular backups are important before updates, plugin changes, or migrations.

Conclusion

Creating a MySQL database for a new website is a standard hosting task, but it should be done carefully. The key steps are simple: create the database, create a dedicated user, assign the user to the database, and add the correct connection details to the website. When set up properly, the site can store content securely and run without avoidable connection errors.

If you are using a hosting control panel such as Plesk, the database tools are usually available in one place, making the process easier to manage. For a new website, it is worth taking a few extra minutes to choose clear names, strong passwords, and the correct permissions. That small effort helps prevent problems later and gives your site a more reliable foundation.

  • 0 Users Found This Useful
Was this answer helpful?