Skip to main content

Mysql Script to install and run mysql instance on linux box



Here is the shell script that will install mysql version 5.5 on a new instance.
sh -xv /root/clean_install.sh

The mysql data directory (/data/mysql/jun19) should be changed in 2 places.

#!/bin/sh

## disable selinux
/usr/sbin/setenforce 0

## shut-down mysql if already running
mysqladmin shutdown

# remove old data directory
rm -rf /var/lib/mysql/
rm -rf /root/download

## create required directories
# datadir
mkdir -p /data/mysql/jun19
# pid directory
mkdir -p /var/run/mysql
# default socket directory
mkdir -p /var/lib/mysql
# download directory
mkdir /root/download
cd /root/download

wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-client-5.5.20-1.linux2.6.x86_64.rpm
wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-devel-5.5.20-1.linux2.6.x86_64.rpm
wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-server-5.5.20-1.linux2.6.x86_64.rpm
wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-shared-5.5.20-1.linux2.6.x86_64.rpm

# create my.cnf file
cat > /etc/my.cnf << "heredoc"
[mysqld]
datadir=/data/mysql/jun19
socket=/var/lib/mysql/mysql.sock
user=root

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysql/mysqld.pid

heredoc

# reset data-directory
mydir=`grep ^datadir /etc/my.cnf | awk -F'=' '{print $2}'`
rm -rf $mydir/*

# remove mysql
for package in `rpm -qa | grep -i mysql`
do
rpm -e $package
done

# install mysql
rpm -iUh /root/download/*

# install mysql system files
mysql_install_db --datadir=$mydir

# restart mysql
/etc/init.d/mysql restart

Comments

Popular posts from this blog

About MySQL - Database history Support and Versioning

About MySQL: MySQL was created by a Swedish company. David Axmark (left) and Michael "Monty" Widenius,  MySQL AB, founded by David Axmark, Allan Larsson and Michael "Monty" Widenius. Original development of MySQL by Widenius and Axmark began in 1994. The first version of MySQL appeared on 23 May 1995. It was initially created for personal usage from mSQL based on the low-level language ISAM, which the creators considered too slow and inflexible. They created a new SQL interface, while keeping the same API as mSQL. By keeping the API consistent with the mSQL system, many developers were able to use MySQL instead of the (proprietarily licensed) mSQL antecedent. Support: The MySQL server software itself and the client libraries use dual-licensing distribution. They are offered under GPL version 2, or a proprietary license. MySQL AB owns the copyright to the MySQL source code. This means that MySQL AB can distribute MySQL under several different l...

MySQL thread error code of 1032- Translate binlog completely to avoid error

Could not execute Update_rows event on table db.table; Can't find record in 'table', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's   master log mysql-bin.262297, end_log_pos 1983208 As of my knowledge the causing stop of slave SQL thread error code of 1032, due to lack of sync between Master - Slave. In our case, slave got an Update event form master, but that particular record was not available in the slave. (Of course, that was deleted on Master n Slave separately) You would get this error only if the binlog_format is set to ROW_BASED or MIXED mode. So, now check that particular binlog at that position where replication stopped with this error. When you convert the binlog with mysqlbinlog command, you may see some junk characters   where you were expecting some DMLs which caused the error(In our case its an Update statement). So you can use below command to translate binlog completely: mysqlbinlog --base64-output=DECO...

Mongodb online Training course Agenda

  Goal:   In this module, you will get an understanding of NoSQL databases, design goals, requirement of NoSQL database/ MongoDB, MongoDB® architecture and introduction to JSON and BSON among others. This module will also cover the installation of MongoDB® and associated tools. Skills Understand NoSQL databases and  advantages Install MongoDB on Windows and Linux platform Security Enable and high availability Objectives After completing this module, you will  be able knowledge ed on SQL and noSQL Database usages and difference between these MongoDB design and architecture  MongoDB GUI tools Describe JSON and BSON Install MongoDB on Windows, Linux, MAC OS etc.  Setup MongoDB environment Topics • Understanding the basic concepts of a Database • Database categories: What is NoSQL? Why NoSQL? Benefit over RDBMS  • Types of NoSQL Database, and NoSQL vs. SQL Comparison, ACID & Base Property • CAP Theorem, implementing NoSQL and what is MongoDB?  • O...