Download
All versions: http://dev.mysql.com/downloads/mysql/
Use 5.7.10 here
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.10.tar.gz
Install dependent packages
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake
Adding MySQL Users and Groups
-s /sbin/nologin mysql
Pre-compilation
cd mysql-5.7.10cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DDOWNLOAD_BOOST=1 -DWITH_BOOST=boost/boost_1_59_0 -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1
Compiling the installation
-l`make install
startup script, setting boot from boot
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqldchkconfig --add mysqldchkconfig mysqld on
Initializing the database
Note:
Previous version mysql_install_db was under Mysql_basedir/script, 5.7 was placed in the Mysql_install_db/bin directory and has been discarded
--initialize
Generates a random password (~/.mysql_secret) without generating a --initialize-insecure
password
- -datadir cannot have data file under target directory
mkdir -p /data/mysqlchown -R mysql:mysql /data/mysql /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
Editing a configuration file
/etc/my.cnf
Reference configuration:
[Client]port =3306socket =/tmp/mysql.sockdefault-character-set = Utf8mb4[mysqld]port =3306socket =/tmp/mysql.sockbasedir =/usr/Local/mysqldatadir =/data/mysqlpid-file =/data/mysql/mysql.piduser = MySQLBind-address =0.0.0.0server-id =1init-connect =' SET NAMES utf8mb4 ' character-set-server = utf8mb4#skip-name-resolve#skip-networkingback_Log =300max_connections =1000max_connect_errors =6000open_files_Limit =65535table_open_cache =128max_allowed_packet =4mbinlog_cache_size =1mmax_heap_table_size =8mtmp_table_size =16MRead_buffer_size =2MRead_rnd_buffer_size =8msort_buffer_size =8mjoin_buffer_size =8mkey_buffer_size =4mthread_cache_size =8query_cache_Type =1query_cache_size =8mquery_cache_Limit =2mft_min_word_len =4Log_bin = Mysql-binbinlog_format = Mixedexpire_logs_days =30Log_error =/data/mysql/mysql-error.logslow_query_Log =1long_query_time =1slow_query_Log_file =/data/mysql/mysql-slow.logperformance_schema =0explicit_defaults_For_timestamp#lower_case_table_names = 1skip-external-lockingdefault_storage_engine = InnoDB#default-storage-engine = Myisaminnodb_file_per_table =1innodb_open_files =500innodb_buffer_pool_size =64minnodb_write_io_threads =4innodb_Read_io_threads =4innodb_thread_concurrency =0innodb_purge_threads =1innodb_flush_Log_at_trx_commit =2innodb_Log_buffer_size =2minnodb_Log_file_size =32minnodb_Log_files_In_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120bulk_insert_buffer_size = 8mmyisam_sort_buffer_size = 8mmyisam_max_sort_file_size = 10gmyisam_repair_threads = 1interactive_ Timeout = 28800wait_timeout = 28800[mysqldump]quickmax_allowed_packet = 16m[myisamchk]key_buffer_ Size = 8msort_buffer_size = 8Mread_buffer = 4mwrite_buffer = 4M
Set Database Password
# 数据库root密码/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to [email protected]‘127.0.0.1‘ identified by \"123456\" with grant option;"/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to [email protected]‘localhost‘ identified by \"123456\" with grant option;"
CentOS Compiler Installation MySQL5.7