DEV Community

Shahriyar Al Mustakim Mitul
Shahriyar Al Mustakim Mitul

Posted on

DevOps Prerequisite (Part 6): Database

Here we will learn about 2 databases
MySQL which is a SQL based databases and MongoDB which is a NoSQL database.
SQL
It basically stores data in rows and column format

Image description

If you want to add any data, all of the data get assigned to a column. You can now provide values for them.

Image description

Here you can see the Salary and Grade column and it's not full. But all of the data has now a column which they can fill or not.

NoSQL
Here it keeps data like pages.

Image description

Image description
You can add extra details here which won't impact other datas. Other data won't have that special label or row at all.

This is the benefit of NoSQL.
This is a json representation of NoSQL database.
Image description

MySQL basics

Image description

Image description

Image description
Use the one time password it generated to login.

Image description
Now, change your default password to a new one.

Image description

You can now check the default databases.

Image description

Image description

Image description

Image description

Image description
Creating user

Image description
Here after the user name, we specify the host . So that the user can only access that host .

Image description

Image description
You can pick any of the permissions from here and assign the user.

Image description

Image description
Labs:
Installing MySQL in Centos

sudo yum install https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

sudo yum install mysql-community-server
Enter fullscreen mode Exit fullscreen mode

Start the MySQL

sudo service mysqld start
Enter fullscreen mode Exit fullscreen mode

Image description
Check the temporary password that has been set for root

sudo grep 'temporary password' /var/log/mysqld.log
Enter fullscreen mode Exit fullscreen mode

Let's change it:
Here we have set the password to P@ssw0rd123 and for this, we checked the demo password and then logged in there. And then changed the password.

Image description
Let's create a new user and set him a password

CREATE USER 'kk_user'@'localhost' IDENTIFIED BY 'S3cure#3214';
Enter fullscreen mode Exit fullscreen mode

Here kk_user is the user and he can access the localserver only . We did set it using "localhost" . We have also set password for him and that is "S3cure#3214".

Image description

Let's grant him all of the access

GRANT ALL PRIVILEGES ON kk_db.* TO 'kk_user'@'localhost';
Enter fullscreen mode Exit fullscreen mode

now we have given kk_user the full access to our database which we created (kk_db) by using * after .

Image description

MongoDB

Stores data in json like format.

Image description
Multiple documents create a document and multiple document creates a database.

Image description

Image description

We can use cloud or server version.

Image description
Here we are using the server version

Image description

Image description

Check the logs

Image description

You can change the host IP from here.

Image description
Connect to mongodb

Image description
No access control is enabled here.
Check databases

Image description
Create a new database and switch to it

Image description
You can now create collections and insert your data.

Image description

Image description

Install MongoDB on Centos

Top comments (0)