# install the basie lib
yum install cmake -y
groupadd mysql
useradd -g mysql mysql
autoreconf --force --install
libtoolize --automake --force
automake --force --add-missing
yum install -y libtoolize
yum install gcc gcc-c++ -y
yum install -y ncurses-devel.x86_64
yum install -y cmake.x86_64
yum install -y libaio.x86_64
yum install -y bison.x86_64
yum install -y gcc-c++.x86_64
yum install make -y # add mysql account,create the basic directory
mkdir -p /data/mysql/data
cd /data/mysql/data
chown -R mysql.mysql /data
chown -R mysql.mysql /usr/local/mysql5711
mkdir -p /data/mysql/binlog/
chown -R mysql.mysql /data/mysql/binlog/
cd /usr/local/mysql5711/ # init databases
rm -rf /data/mysql/data/*
cp my.cnf /usr/local/mysql5711/my.cnf
time bin/mysqld --defaults-file=/usr/local/mysql5711/my.cnf --initialize --user=mysql # set the auto start on linux server started
cp support-files/mysql.server /etc/init.d/mysql
chmod 700 /etc/init.d/mysql
echo "export PATH=$PATH:/usr/local/mysql5711/bin">>/etc/profile
source /etc/profile
chkconfig --add mysql # do a soft link to start mysql
cd /usr/local/
ln -s /usr/local/mysql5711 mysql # remove default my.cnf
mv /etc/my.cnf /tmp/ # set the default password
/usr/local/mysql/bin/mysqld_safe --skip-grant-tables --skip-networking &
/usr/local/mysql/bin/mysql -uroot --password='' --socket='/usr/local/mysql/mysql.sock' -e " update mysql.user set authentication_string=password('dns_yuerld') where user='root' and Host = 'localhost'; flush privileges;"
/usr/local/mysql/bin/mysql -uroot --password='dns_yuerld' --socket='/usr/local/mysql/mysql.sock' -e " set PASSWORD=PASSWORD('dns_yuerld'); create database t; create table t1 select 1 as a; select * from t1;" # restart the mysql server
service mysql restart # check the test
/usr/local/mysql/bin/mysql -uroot --password='dns_yuerld' --socket='/usr/local/mysql/mysql.sock' -e " select * from t1;"
4,批量安装很多mysql实例
将脚本和安装软件scp到N台服务器,然后ssh ip地址 " sh /soft/init_linux.sh; sh /soft/install_mysql.sh;",用后台批量进程来安装。5,why?采用二进制安装而不采用源码安装 主要是源码安装在make环节需要消耗太多时间,一次源码安装mysql需要很久,而二进制安装免去了configure、make、make install这一步骤,大大缩减了安装时间提升了效率,单台安装mysql感觉不大,如果一次性安装成千上万台,这个差距就是天上地下咯。