mkdir -p /opt/software/mysql && cd /opt/software/mysql
wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
tar -zxf mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
ln -s /opt/software/mysql/mysql-5.7.10-linux-glibc2.5-x86_64 /usr/local/m,ysql
groupadd mysql
useradd -r -g mysql mysql
mkdir -p /data/mysql/3306/{data,undo,etc}
chown -R mysql:mysql /data/mysql/3306/
配置文件可参考姜承尧老师的配置文件,实际上还是最小化为好,姜老师的是5.6和5.7通用,对于5.7来说,姜老师的配置文件里很多配的都是默认值,碰到这样的我在我自己的配置文件中就没写了:http://www.innomysql.net/article/21730.html
**************************************************************************************************
我自己的配置文件/data/mysql/3306/etc/my.cnf:
[client]
user=mysql
socket = /tmp/mysql3306.sock
[mysqld]
#########basic settings######################
#每个实例有一个单独的实例编号,命名最好是ip最后一段+端口号
server-id = 643306
#端口号
port = 3306
#默认启动用户
user = mysql
#此server实例绑定地址
bind_address = 192.168.1.64
#server字符集设置,utf8mb4是utf8超集,包含eomoji及ios存储表情
character_set_server = utf8mb4
#禁止dns解析,默认开启,应该关闭,会导致响应变慢,初始化时记得注释掉,负责生成不了用户权限和密码,等启动后修改root密码后可以再打开
#skip_name_resolve = 1
max_connections = 800
#当超过设定次数,会拒绝远程连接,此时若想远程客户端继续连接,需要flush hosts
max_connect_errors = 10000
#软件目录
basedir = /usr/local/mysql
#数据目录
datadir = /data/mysql/3306/data
tmpdir = /tmp
socket = /tmp/mysql3306.sock
explicit_defaults_for_timestamp = 1
########log settings#########################
log_error = error.log
slow_query_log = 1
slow_query_log_file = slow.log
log_queries_not_using_indexes = 1
log_slow_admin_statements = 1
log_slow_slave_statements = 1
log_throttle_queries_not_using_indexes = 10
expire_logs_days = 7
long_query_time = 2
########innodb settings############
innodb_buffer_pool_size = 500MB
innodb_buffer_pool_instances = 2
#预热参数,默认为25%,5.7.7默认打开
innodb_buffer_pool_dump_pct = 40
#脏叶刷新线程,与innodb_buffer_pool_instances数量配置一致
innodb_page_cleaners = 2
#undo独立分开,可以放置于高速磁盘
innodb_undo_directory = /data/mysql/3306/undo/
innodb_undo_logs = 128
innodb_undo_tablespaces = 3
#打开undo清空,undo表空间必须至少大于2个,回滚段个数必须大于35个
innodb_undo_log_truncate = 1
innodb_max_undo_log_size = 1G
##########repl settings##################
master_info_repository = TABLE
relay_log_info_repository = TABLE
log_bin = bin.log
sync_binlog = 1
gtid_mode = on
enforce_gtid_consistency = 1
log_slave_updates
binlog_format = row
binlog_gtid_simple_recovery = 1
slave_skip_errors = ddl_exist_errors
**************************************************************************************************
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/3306/etc/my.cnf --initialize
/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql3306/etc/my.cnf &
启动后可查看日志,日志里有临时密码,使用此密码登陆,重新生成密码
2015-12-23T08:29:26.639724Z 1 [Note] A temporary password is generated for root@localhost: ra2rR+uyuO4c
mysql -S /tmp/mysql3306.sock -uroot -p
mysql> alter user root@'localhost' identified by 'yournewpassword';
至此,mysql安装完成,正常启动,此时将skip_name_resolve=1打开,然后重启