Thursday, June 24, 2021

create Elastic Search Database backup


1.Make a zip from elasticsearch folder by executing, `tar -czvf backup.tar.gz elasticsearch`

 =========


Existing database table values display as follows.



2. Stop elastic search db

3. rename it's db data folder to different name


4. extract previously taken db backup using below command

tar -xvf backup.tar.gz
 

 5. Now you can see the extract elasticsearch data folder as follows

 6.start elastic search db using below command
sudo service elasticsearch start
7. recheck the data using the postman

 



Wednesday, June 23, 2021

Uninstall MySQL On Ubuntu OS

 1. open Terminal and execute below command

sudo systemctl stop mysql

this command will stop mysql service

2. Next run below command

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*

3.Below command will remove MySQL configuration and data.

sudo rm -rf /etc/mysql /var/lib/mysql

 


4.

(Optional) Remove unnecessary packages.

sudo apt autoremove

(Optional) Remove apt cache.

sudo apt autoclean


MySQL Database DB Bakup from Ubuntu OS

MySQL DB back can be taken as below Terminal command

 

sudo mysqldump -p mailhub >/home/pasindu/a.sql




restore mysql DB using the below command


mysql -u username -p database_name < backup_name.sql

 

Below commands are used to stop mysql service

sudo service mysql stop

or 

sudo systemctl stop mysql
 

Below command is used to start mysql service

sudo service mysql start
 

Create mysql user for MySQL database

 Create new mysql user 

CREATE USER 'sunny'@'localhost' IDENTIFIED BY 'sunny';


GRANT ALL PRIVILEGES ON *.* TO 'sunny'@'localhost' WITH GRANT OPTION;


This user has all privileges

username : sunny

password: sunny

Install MySQL on Ubuntu 18.04

 Install mysql database on the Ubuntu OS.

1. open terminal

 execute below command

sudo apt-get update
2. sudo apt-get install mysql-server

3.sudo systemctl status mysql - check status of mysql db

4.sudo mysql_secure_installation
It's asking for Root new password
5.For all the other asking questions  enter 'y'
 

 
6.Next enter mysql -u root -p
Then it's ask for password
After that It's giving below error message.
7.
 Then enter sudo mysql command


8. After that enter below sql query

SELECT user,authentication_string,plugin,host FROM mysql.user;

you can see output as follows


then I change Root password as follows.

 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '257F257f';



9.then press below sql query.

FLUSH PRIVILEGES;

10. next see below sql query.

SELECT user,authentication_string,plugin,host FROM mysql.user;


Now output will be as follows.

You can see in this example output that the root MySQL user now authenticates using a password. Once you confirm this on your own server,
you can exit from mysql shell using exit command.
Next login to my sql you have to do following command
 
mysql -u root -p
 



Sunday, June 20, 2021

Elastic Search Database

 Elastic Search database is no-sql database.

Below are the comparison with Elastic Search Database items with Relation Database Item.


create index using below command line


If below http://localhost:9200/_cat/indices  on brower contains yellow one,you have to run below command

curl -XPUT 'http://localhost:9200/_settings' -H 'Content-Type: application/json' -d '
{
    "index" : {
        "number_of_replicas" : 0
    }
}'



Tuesday, June 15, 2021

setup nginx Server reverse proxy on Windows 10

 Nginx is famous server to do a reverse proxy.

 Here I am setting up how to setup Nginx