Your Gateway To Digital Success
Wesbytes Blue Logo

Wesbytes Knowledge Base

Search our articles or browse by category below

How to Create MySQL Database

Last modified: July 2, 2022
You are here:
Estimated reading time: 1 min

Create MySQL Database 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:
    1. GRANT ALL PRIVILEGES ON *.* TO 'db_user'@'localhost' IDENTIFIED BY 'P@s$w0rd123!';

      NOTE: Be sure to replace db_user and P@s$w0rd123! with the actual name and the password to be given to the database user.

 

    1. After that, log out of MySQL by typing: \q.
    2. Log in as the new database user you just created.
    3. mysql -u db_user -p

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

      Lastly, create a new database:

      CREATE DATABASE db_name;

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

Was this article helpful?
Dislike 0
Views: 6