Casbay Knowledge Base

Search our articles or browse by category below

HOW TO: Create MySQL Database

Last modified: May 12, 2021
You are here:
Estimated reading time: 1 min

Create MySQL Database

Create MySQL Databse with cPanel

  1. Firstly, sign into your Control Panel.

  2. Then, click on Databases.

  3. Enter a database name and press Add.

  4. Lastly, enter a username and password for the database and press Update.

  5. Your connection is localhost and the username and passwords are what you have specified in the setup. This data is required when a script associate with mySQL server.

Create MySQL Database with Command

For those who are running a Linux server with MySQL but no cPanel, you can use MySQL commands to easily create a MySQL database, database user, password, and assign all privileges to the user for the database.

  1. Firstly, SSH into your server.

  2. Secondly, login to MySQL as root user.

  3. Then, create a new database user with:
    GRANT ALL PRIVILEGES ON *.* TO 'db_user'@'localhost' IDENTIFIED BY '[email protected]$w0rd123!';
    NOTE: Be sure to replace db_user and [email protected]$w0rd123! with the actual name and the password to be given to the database user.

  4. After that, log out of MySQL by typing: \q.

  5. Log in as the new database user you just created.
    mysql -u db_user -p
    Then, type the new database user’s password and press Enter.

  6. Lastly, create a new database:
  7. CREATE DATABASE db_name;
    NOTE: Be sure to modify db_name with the actual name you would like to give the database.

We hope this article helped you to learn how to create MySQL Database. For more articles, please go to Knowledge Base.

Was this article helpful?
Dislike 0
Views: 20