Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to create a new MySQL database

This guide shows you two ways to make a new MySQL database: with cPanel and with a command.

Databases2 min read13 steps2 screenshots

What is MySQL?

MySQL is a popular system for storing data. A database made with MySQL is like a filing cabinet. Websites use it to keep posts, users and settings. Each site usually has its own database.

Way 1: Use cPanel (easiest)

cPanel is the control panel on most shared hosting plans.

Manage My Databases
  1. Log in to your client area. Open your hosting service and log in to cPanel.
  2. Under Databases, click MySQL Databases.
  3. In the New Database box, type a name.
  4. Click Create Database.
    database name, username and password
  5. Add a user: under MySQL Users, type a user name and a strong password, then click Create User.
  6. Under Add User To Database, choose the user and the database. Click Add.
  7. Tick ALL PRIVILEGES, then click Make Changes.

cPanel puts your account name in front of both names. Write down the full names and the password.

Way 2: Use the command line

This way is for VPS or dedicated server customers, or anyone with MySQL access over SSH. SSH is a safe way to type commands on a remote server.

  1. Log in to your server with SSH.
  2. Open MySQL:
    mysql -u root -p
    This starts MySQL as the admin user and asks for the password.
  3. Create the database:
    CREATE DATABASE mydatabase;
    This makes an empty database named mydatabase. Use your own name.
  4. Create a user:
    CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'StrongPassword';
    This makes a user with a password.
  5. Give the user rights:
    GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';
    FLUSH PRIVILEGES;
    This lets the user work with that database. The second line reloads the rights.
  6. Leave MySQL with EXIT;
Tip: Use simple names with letters, numbers and underscores. Avoid spaces and special marks.

Check it worked

In MySQL, type SHOW DATABASES;. Your new database should appear in the list.

Quick recap

  • A MySQL database stores your site's data.
  • In cPanel, use MySQL Databases: create the database, the user, then link them.
  • On a server, use CREATE DATABASE, CREATE USER and GRANT.
  • Save the names and password safely.