首先从官网下载zip archive版本http://dev.mysql.com/downloads/mysql/
MySQL v5.7.19 官方正式版(32/64位 安装版与zip解压版)
一、优化部分
1.操作系统参数调优
2.数据库参数调优
3.防火墙设置等
#############################
二、安装部分
1.创建用户和组
# groupadd mysql# useradd -g mysql mysql |
2.创建数据库安装目录、授权
# mkdir /mysql /mysql/data /mysql/log # chown -R mysql:mysql /usr/local/mysql |
3.到安装目录,解压安装文件
#cd /usr/local# tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz# mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql |
4.授权
# chown -R mysql.mysql mysql |
5.验证权限
# ls -l mysqltotal 52drwxr-xr-x 2 mysql mysql 4096 Aug 8 04:06 bin-rw-r--r-- 1 mysql mysql 17987 Jun 22 22:13 COPYINGdrwxr-xr-x 2 mysql mysql 4096 Aug 8 04:06 docsdrwxr-xr-x 3 mysql mysql 4096 Aug 8 04:06 includedrwxr-xr-x 5 mysql mysql 4096 Aug 8 04:06 libdrwxr-xr-x 4 mysql mysql 4096 Aug 8 04:06 man-rw-r--r-- 1 mysql mysql 2478 Jun 22 22:13 READMEdrwxr-xr-x 28 mysql mysql 4096 Aug 8 04:06 sharedrwxr-xr-x 2 mysql mysql 4096 Aug 8 04:06 support-files |
6.编辑参数文件
vim /etc/my.cnf[client]port = 3306socket = /tmp/mysql.sock[mysqld]server_id=10port = 3306user = mysqlcharacter-set-server = utf8mb4default_storage_engine = innodblog_timestamps = SYSTEMsocket = /tmp/mysql.sockbasedir = /usr/local/mysqldatadir = /mysql/datapid-file = /mysql/data/mysql.pidmax_connections = 1000max_connect_errors = 1000table_open_cache = 1024max_allowed_packet = 128Mopen_files_limit = 65535#####====================================[innodb]==============================innodb_buffer_pool_size = 1024Minnodb_file_per_table = 1innodb_write_io_threads = 4innodb_read_io_threads = 4innodb_purge_threads = 2innodb_flush_log_at_trx_commit = 1innodb_log_file_size = 512Minnodb_log_files_in_group = 2innodb_log_buffer_size = 16Minnodb_max_dirty_pages_pct = 80innodb_lock_wait_timeout = 30innodb_data_file_path=ibdata1:1024M:autoextendinnodb_undo_tablespaces=3#####====================================[log]==============================log_error = /mysql/log/mysql-error.log slow_query_log = 1long_query_time = 1 slow_query_log_file = /mysql/log/mysql-slow.logsql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES |
7.安装数据库
# ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp |
8.配置启动文件
cp support-files/mysql.server /etc/init.d/mysqlchkconfig --add mysqlchkconfig mysql onservice mysql start |
9.配置环境变量