# How to create a MySQL database

> Create the database and user, grant the right permissions, and write down the four values you will need next.

Source: https://cwp.sg/tutorials/create-a-mysql-database/  
Author: Ben Johnson  
Last verified: 2026-09-21

**In short:** - The database host in CWP shared hosting is never "localhost" — find the specific address shown in the MySQL section of your control panel. - Create one database and one dedicated user per application, using the password generator for a strong random password. - Link the user to the database with all privileges, then note the four values: host, database name, username, and password. - Your free account allows only 5 concurrent MySQL connections, so close connections after each query to avoid a "too many connections" error.

To install most web applications, you need four pieces of information: the database host, the database name, the database username, and the password. You create all of these in your control panel. If you get any of them wrong, the application shows an [error establishing a database connection](/errors/error-establishing-a-database-connection/).

## Find the database host

On some shared hosting the database runs on the same machine and the host is `localhost`. On others — including some CWP setups — it sits on a separate server, and the panel gives you a specific address instead. In your CWP control panel, look at the **MySQL** section. The panel tells you the host. It looks like `srv127.cwp.sg` or `10.10.0.12`. Write it down exactly as it appears. A single typo and the application cannot connect. Copy the host string directly from the panel. Do not guess it.

## Create the database

1. Log into your CWP control panel.
2. Click **MySQL Databases** under the Databases heading.
3. In the **Create New Database** field, type a name. Use your account prefix and a short description of the app, for example `johndoe_wordpress`.
4. Click **Create Database**. The database appears in the list.

You have a limit of 400 databases on a free account. That number is generous. The limit that bites is something else, and it comes next.

## Create a database user

Never reuse a database password across applications, and never reuse a database user. One user per application, one random password per user. If one site gets compromised, the others stay safe. Creating separate users also makes it easier to revoke access later if you remove an application.

1. In the same **MySQL Databases** page, scroll to **Add New User**.
2. Type a username. Match it to the database name, for example `johndoe_wpuser`.
3. Use the [password generator](/tools/password-generator/) to create a strong password. Copy it and paste it into the password field and the confirm field. Do not type a password yourself. Do not use "password123" or any word from a dictionary.
4. Click **Create User**.

## Link the user to the database

1. In the **Add User to Database** section, select the user you just created from the first dropdown.
2. Select the database from the second dropdown.
3. Click **Add**.

A screen appears asking for privileges. For a typical application such as WordPress, Joomla, or Drupal, tick **All Privileges** and click **Make Changes**. If you know exactly which database operations the application needs, you can grant only those. Most people do not need to guess, so tick all of them. The application will manage the database on its own.

You now have four values:

- **Host**: whatever the panel showed you (not "localhost")
- **Database**: `johndoe_wordpress`
- **User**: `johndoe_wpuser`
- **Password**: the long random string from the password generator

## The concurrency limit that matters

Your free account allows 400 databases but only **5 concurrent MySQL connections**. That means only five things can talk to MySQL at the same time across all of your databases. If you install a sixth application that opens a persistent connection, the server refuses it and you see a [too many connections](/errors/too-many-connections/) error.

To stay under the limit, use non-persistent connections in your code. Most applications do this by default. If you are writing your own scripts, read the guide on [using it from code](/tutorials/connect-php-to-mysql/) to check you are connecting the right way. The short version is: open the connection, run the query, close the connection. Do not hold it open waiting for the next HTTP request. Each open connection counts against your limit of five.

## Keep your password safe

You cannot recover a database password from CWP. The panel stores a hash, not the plain text. If you lose it, you must create a new user, link it to the database, grant privileges again, and update the application configuration. So store the password somewhere you can find it, such as a password manager. Do not paste it into a shared document or a public support thread.

## Shared hosting and database setup

The host, database name, user, and password are the only things MySQL needs to let your application in. Write them down on paper or in a password manager the moment you create them. When the application asks, you supply exactly those four values. Any mistake means the application cannot talk to the database, and you have to troubleshoot the connection from the start. A correct setup means the application can read and write its data, and you do not see a database error on screen.

---

Content Website Platform (cwp.sg) operates the free hosting it writes about; see https://cwp.sg/about/ for the methodology and the commercial disclosure.
