mysql-5.6._mysql-5.6安装

#!/bin/bash

###安装mysql5.6cd/usr/local/src/wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.40.tar.gz

tar xf mysql-5.6.40.tar.gz

cd mysql-5.6.40

yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* makecmake

useradd-s /sbin/nologin -M mysqlmkdir /data/mysqldata -pchown -R mysql.mysql /data/mysqldata

cmake \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/data/mysqldata/data \-DSYSCONFDIR=/etc \-DWITH_MYISAM_STORAGE_ENGINE=1\-DWITH_INNOBASE_STORAGE_ENGINE=1\-DWITH_MEMORY_STORAGE_ENGINE=1\-DWITH_READLINE=1\-DMYSQL_UNIX_ADDR=/data/mysqldata/mysql.sock \-DMYSQL_TCP_PORT=3306\-DENABLED_LOCAL_INFILE=1\-DWITH_PARTITION_STORAGE_ENGINE=1\-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_cimake && make installcp support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqldecho export PATH=`echo $PATH:/usr/local/mysql/bin` >> /etc/profileexport PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin

##修改/etc/my.cnf文件cp /etc/my.cnf{,.bak`date +%Y-%m-%d`}cat>/etc/my.cnf<

[client]

port = 3306

socket = /tmp/mysql.sock

[mysqld]

port = 3306

socket = /tmp/mysql.sock

back_log = 50

skip-name-resolve

default-storage-engine = innodb

slow_query_log

slow-query-log-file=/data/mysqldata/localhost-slow.log

datadir = /data/mysqldata

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

[myisamchk]

key_buffer_size = 512M

sort_buffer_size = 512M

read_buffer = 8M

write_buffer = 8M

[mysqlhotcopy]

interactive-timeout

[mysqld_safe]

open-files-limit = 8192

EOF

cd /usr/local/mysql

scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysqldata --user=mysql

#启动mysql/etc/init.d/mysqld start

##初始化数据库

mysql-e "DELETE FROM mysql.user WHERE User='';"mysql-e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"mysql-e "DROP DATABASE IF EXISTS test;"mysql-e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';"mysql-e "FLUSH PRIVILEGES;"

你可能感兴趣的:(mysql-5.6.)