How to Create Your First Database Using MySQL: A Step-by-Step Guide.

What is MySQL?

MySQL is a type of relational database management system that uses Structured Query Language (SQL) to manage and manipulate data.

Use this command to install MySQL from the terminal

sudo dnf install mysql-community-server

Visit the official MySQL developers' site website for the installation for Windows or Mac.

Start the MySQL Server and enable it at the login

sudo systemctl start mysqld
sudo systemctl enable mysqld

Login to MySQL as the root

sudo -u root -p

Enter your MySQL root password when prompted.

I recommend creating a different user besides the root user for all your basic CRUD operations.

Create a user

CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';

Grant privileges for CRUD to this user

GRANT INSERT, DELETE, CREATE, UPDATE ON *.* TO 'user'@'localhost';

Flush all privileges to apply changes

FLUSH PRIVILEGES;

Login as the new user

mysql -u 'yourUsername' -p

You will be prompted to enter your password.

Now that you have installed and configured your system for MySQL, it's time to create your database and propagate it with data.

You might want to check the particular user in case you have created multiple users.

Check the current user

SELECT CURRENT_USER();

Create your database

CREATE DATABASE firstDatabase;

Use database

USE firstDatabase;

Create a table in this database that contains useful information a

CREATE TABLE employees(
    empId INT PRIMARY KEY,
    first_name VARCHAR(25),
    last_name VARCHAR(25),
    date_of_birth DATE,
    email_address VARCHAR(75)
);

Populate your data with information

INSERT INTO employees VALUES (00001, "Kwabena", "Twumasi", "01-01-1999","ktwum721@gmail.com")

Congratulations you have created your first database with a table that has been populated with data.

ย