InMotion Hosting Support Center

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.

IMPORTANT: This guide is inteneded for use with our Cloud VPS (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 Database Using MySQL CLI

If you are running a Linux server with MySQL but no cPanel, you can simply use MySQL commands to create the MySQL database, database user and password, as well as, assign all privileges to the user for the database.

  1. SSH into your server.

  2. Log into MySQL as the root user.

  3. Create a new database user:

    GRANT ALL PRIVILEGES ON *.* TO 'db_user'@'localhost' IDENTIFIED BY 'P@s$w0rd123!';

    NOTE: Be sure to modify db_user with the actual name you would like to give the database user, as well as, P@s$w0rd123! with the password to be given to the user.

  4. Log out of MySQL by typing: \q.

  5. Log in as the new database user you just created:

    mysql -u db_user -p

    NOTE: Be sure to modify db_user with the actual database user name.

    Then, type the new database user's password and press Enter.

  6. Create the new database:

    CREATE DATABASE db_name;

    NOTE: Be sure to modify db_name with the actual name you would like to give the database.


Congratulations! Now, you know how to use MySQL from the command line to create a database. Want to learn more? Check out our guide on How to Import MySQL Databases in Command Line.

Was this article helpful?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Support Center Login

Our Login page has moved. Please click the button below to be redirected to the login page.

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

0 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!