diff --git a/M-AB.sh b/M-AB.sh deleted file mode 100644 index bbdebb7..0000000 --- a/M-AB.sh +++ /dev/null @@ -1,164 +0,0 @@ -#!/bin/bash - -### This script will install the mysqld from the binary files.User can download the binary files -### from the mysql official website. Only condition for this script to work is that the tar or zipped file should be untar and the folder should be in a place. -### This script will start from creating the group and user and if already exist will skip to the next path where it will create the data directory,log directory -### and the configuration file after taking input from the user. - - -########### Step 0 to check if there is already an existing process of mysql ###################### - -echo "Checking if mysqld is already running on this system" -is_running=yes -ps cax | grep mysql > /dev/null -if [ $? -eq 0 ]; - then - echo "mysqld is already running." - echo "Do you want to kill this process and re install database" - read input - if [ "${input^^}" == "${is_running^^}" ]; - then - id=$(ps cax | grep mysql | grep -o '^[0-9]*') - echo $id && kill $id - echo "Process "$id "has been killed successfully. Proceeding towards the installation" - else - echo "exiting this programm" - exit 1 - fi - else - echo "Process is not running and hence proceed towards the installation" -fi - - -sleep 3 - - -############# Step 1 is to check if mysql group exist #################### -b=mysql - -echo "Checking if group "$b "already exist and if not create one........." - -a=$(grep mysql /etc/group | cut -d : -f 1) -if [ "$a" = $b ]; - then - echo "Group "$b "already exist" - else - echo "Group "$b "not exist and thus adding..." - groupadd mysql - result=$? - if [ "$result" = 0 ]; - then - echo "group succesfully added" - else - echo "group addition failed" - fi -fi - -sleep 2 - -########### Step 2 is to create the user mysql and add it to the group mysql################ - -echo "Now Add user "$b - -useradd -r -g $b $b 2>/dev/null -result=$? - - if [ "$result" = 0 ]; - then - echo "user succesfully added to the group "$b - else - echo "user already existing" - fi - -sleep 2 - -############## Step 3 is to create the data directory, log file directory, configuration file with minimum parameters required to start mysqld ################# - -echo "Enter the data directory path.For example /data01/" -read dpath - -until mkdir $dpath 2>/dev/null - do - mkdir $dpath 2>/dev/null - echo "this path already exist. Please try again" - read dpath - done -chmod -R 750 $dpath && chown -R mysql:mysql $dpath -echo "Data directory created and permission and ownership assigned" - -sleep 2 - -echo "Now creating the log file directory where error file exist. Please enter the log directory.For example /log01" -read lpath - -until mkdir $lpath 2>/dev/null - do - mkdir $lpath 2>/dev/null - echo "this path already exist. Please try again" - read lpath - done - - echo "creating log error file now...." - touch $lpath/error.log && chmod -R 750 $lpath && chown -R mysql:mysql $lpath - echo "created successfully" - echo "log directory successfully created, permission and ownership assigned" - - -sleep 2 - -echo "cnf file will be created in the /etc folder for ease of understanding and user can move it to another location if required....." -echo "creating now...." - -touch /etc/my.cnf - result=$? - if [ "$result" = 0 ]; - then - echo "cnf file succesfully created adding parameters now" - a="[mysqld]" - b="user=mysql" - c="datadir=$dpath" - d="log-error=$lpath/error.log" - echo -e "$a\n$b\n$c\n$d" > /etc/my.cnf - else - echo "configuration file not created..." - fi -sleep 2 - -######## Step 4 ################### - -echo "Now mysql database will install.Installing........" -echo "please provide the path to the mysql bin folder. For example /mysql-8.0.23-linux-glibc2.12-x86_64/bin" -read mysqld -echo "database installing........." -$mysqld/mysqld --datadir=$dpath --initialize --user=mysql - - if [ "$result" = 0 ]; - then - echo "database has been successfully installed under "$dpath - else - echo "Database creation failed please check..." - fi -sleep 3 - -########## Step 5 ################### - -echo "initialising database..........." -nohup $mysqld/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql > /dev/null 2>&1 & -result=$? - if [ "$result" = 0 ]; - then - echo "Database has been initialised successfully" - else - echo "Not installed...Error in installing" - fi - -sleep 2 -########## Step 6 ################### - -######## to change the password ####### - -rpassword=$(grep -w "A temporary password is generated for root@localhost" $lpath/error.log | cut -d " " -f 13) -echo "Your password is "$rpassword -echo "Login into database using mysql -uroot -p'"$rpassword"'and change the password using alter user root@localhost identified by 'your password'; and then followed by 'flush privileges;'" -sleep 2 -echo "exiting now...." diff --git a/README.md b/README.md deleted file mode 100644 index 7a4362c..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# M-AB - -MySQL automatic binary installation. Usually to make our life easy while installing mysql we usually use rpm files which straight away install the mysql engine on the linux machine. But one of the main disadvantage is that it bound you with the file locations or the path locations of data directory or log file (where error log resides ). User cannot choose the file location on their own and user needs to rely on rpm packages solely. This can also cause security issues because the file location will remain same and will be easy to find the paths. But with binary installation i.e. tar file user has an independence to define their own path and has an option to make sure if all the files has been successfully installed. Moreover in case if mysql is not running then it becomes quite easy to troubleshoot. With M-AB user can install the mysqld according to their own requirements i.e without going through all the steps needed to execute manually in tar files. M-AB will start from checking if any other mysqld is already running on the system. With M-AB user should make sure that the untar file of mysql must be placed on the system (where mysql required to be installed) before running this programm.