标签:scripts socket _for nss my.cnf binlog set 5.6 commit
#!/bin/bash
#system:Centos7
#mysql.tar.gz is glibc
#Download url https://dev.mysql.com/downloads/mysql/
#Example download
#https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz
#sh mysql_install.sh mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz
case $1 in
"")
echo "Example: sh mysql_install.sh mysql-glibc.tar.gz"
exit 1;;
*)
if test ! -f $1
then
echo "Dir or Filename Error!"
else
yum -y install autoconf libaio-devel perl-Module-Install.noarch
mkdir /opt/mysql
mkdir /data
tar -xvf $1 -C /opt/mysql --strip-components 1
useradd -r mysql -s /sbin/nologin
chown -R mysql.mysql /data
chown -R mysql.mysql /opt/mysql
cd /opt/mysql/scripts/
./mysql_install_db --basedir=/opt/mysql/ --datadir=/data --user=mysql --pid-file=/opt/mysql/mysql.pid
cp /opt/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
cat>/etc/my.cnf <<END
[mysqld]
basedir = /opt/mysql
datadir = /data
socket = /tmp/mysql.sock
pid-file =/opt/mysql/mysql.pid
log-bin=mysql-bin
binlog_format=mixed
character-set-server = utf8
max_connections = 1000
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
interactive_timeout = 28800
wait_timeout = 28800
lower_case_table_names=1
event_scheduler=1
skip-name-resolve=1
max_allowed_packet=30M
END
ln -s /opt/mysql/bin/* /usr/sbin/
/etc/init.d/mysqld start
echo "/etc/init.d/mysqld start" >>/etc/rc.local
chmod +x /etc/rc.local
mysql_passwd=`openssl rand -base64 9`
mysqladmin -u root password "$mysql_passwd"
mysql -uroot -p$mysql_passwd -e "delete from mysql.user where user=‘‘; delete from mysql.db where user=‘‘;"
echo "port 3306"
echo "basedir /opt/mysql"
echo "datadir /data"
echo "root passwd:$mysql_passwd"
fi
;;
esac
标签:scripts socket _for nss my.cnf binlog set 5.6 commit
原文地址:http://blog.51cto.com/quliren/2171301