
If you need to create a database for your website there are multiple ways to do it. In this guide, you can learn how to create a MySQL database using the command line interface (CLI).
IMPORTANT: This guide is intended for use with our Cloud Server Hosting and other hosting plans that do not include cPanel. If your server includes cPanel, you should follow our guide on How to Create a MySQL Database Using the cPanel API.
Create a MySQL Database Using CLI
If you are running a Linux server with MySQL but no cPanel, you can simply use the terminal to create a MySQL database, database user, and password, as well as, assign all privileges to the user for the database.
- SSH into your server as root.
- Log into MySQL as root:
mysql -u root
- Create a new database user:
GRANT ALL PRIVILEGES ON *.* TO 'db_user'@'localhost' IDENTIFIED BY '[email protected]$w0rd123!';
NOTE: Be sure to modifydb_user
with the actual name, you would like to give the database user, as well as,[email protected]$w0rd123!
with the password to be given to the user. - Log out of MySQL by typing:
\q
. - Log in as the new database user you just created:
mysql -u db_user -p
NOTE: Be sure to modifydb_user
with the actual database user name.Then, type the new database user’s password and press Enter.
- Create a new database:
CREATE DATABASE db_name;
NOTE: Be sure to modifydb_name
with the actual name you would like to give the database.

Congratulations! Now, you know how to create a MySQL database from the command line. Want to learn more about database management? Check out official MySQL documentation or our guide on How to Import MySQL Databases in Command Line.
If you don’t need cPanel, don't pay for it. Only pay for what you need with our Cloud VPS solutions.
CentOS, Debian, or Ubuntu
No bloatware
SSH Key management made easy