CentOS6.9 Compiling and installing MySQL5.7.16
Deployment environment:
System Centos6.9,mysql5.7.16,boost Library
System is 2G memory
1, install the dependency package, use Yum to install cmake,6.9 default Yum from the band
Yum-y Install gcc-c++ cmake bison-devel ncurses-devel
2. Create a MySQL User:
Useradd-u-s/sbin/nologin MySQL
3. Create the necessary folders and modify their directory user owners:
Mkdir-pv/usr/local/mysql/etc
Mkdir-pv/data/{boost/boost_1_59_0,mysql/{data,log}}
Chown-r mysql:mysql/usr/local/mysql/
Chown-r mysql:mysql/data/mysql/
4. Copy the Boots Library to the Boost directory
cp/tmp/boost/boost_1_59_0/*/data/boost/boost_1_59_0
Chown-r mysql:mysql/data/boost/
5. Compile and install mysql5.7
Cd/tmp
Tar XF mysql-5.7.16.tar.gz
CD mysql-5.7.16
CMake \
-dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/data/mysql/data \
-DSYSCONFDIR=/USR/LOCAL/MYSQL/ETC \
-dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_memory_storage_engine=1 \
-dwith_readline=1 \
-dmysql_unix_addr=/data/mysql/log/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_CI \
-dwith_boost=/data/boost/boost_1_59_0
Make && make install
Longer time
Chown-r Mysql:mysql/usr/local/mysql
6. configuration file my.cnf
[Client]
Port = 3306
Socket =/data/mysql/log/mysql.sock
[MySQL]
Default-character-set = UTF8
[Mysqld]
# file
DataDir =/data/mysql/data
Basedir =/usr/local/mysql
Pid-file =/data/mysql/log/mysqld.pid
Log_error =/data/mysql/log/mysql.err
Port = 3306
Socket=/data/mysql/mysql.sock
User=mysql
Character_set_server = UTF8
Character_set_server = UTF8
Slow_query_log = 1
Slow_query_log_file =/data/mysql/log/slowq.log
Long_query_time = 1
Log-bin=/data/mysql/log/mysql-bin.log
# Temp
Max_tmp_tables = 64
Tmp_table_size = 512M
Slave_load_tmpdir =/data/mysql/log
Tmpdir =/data/mysql/log
# session
Back_log = 512
Skip-name-resolve
Max_allowed_packet = 32M
Max_connections = 16000
Max_connect_errors = 10000
Wait_timeout = 28800
Table_open_cache = 216
Thread_cache_size = 128
Query_cache_type = 0
Query_cache_size = 0
Key_buffer_size = 128M
Myisam_sort_buffer_size = 16M
Read_buffer_size = 16M
Read_rnd_buffer_size = 16M
Sort_buffer_size = 16M
Join_buffer_size = 16M
# InnoDB
Default_storage_engine = InnoDB
Innodb_data_home_dir =/data/mysql/data
Innodb_data_file_path = Ibdata1:256m:autoextend
Innodb_log_group_home_dir =/data/mysql/log
Innodb_log_files_in_group = 4
Innodb_log_file_size = 256M
Innodb_log_buffer_size = 8M
Innodb_flush_log_at_trx_commit = 2
Innodb_flush_method = O_direct
Innodb_lock_wait_timeout = 50
#innodb_thread_concurrency = 24 16
Innodb_buffer_pool_size = 1G
innodb_io_capacity = 1500
Innodb_use_native_aio = 1
innodb_file_per_table = 1
Innodb_open_files = 3000
# others
Memlock = 1
Performance_schema = 0
# replication
Server-id = 150
Binlog_format = row
Expire_logs_days = 7
Relay_log =/data/mysql/log/relay-bin
#replicate_ignore_db = MySQL
#slave_skip_errors = 1062
Log_slave_updates = 1
Skip-slave-start
READ_ONLY = 0
Sync_binlog = 1
[Mysqldump]
Default-character-set = UTF8
[mysqld-5.7]
innodb_buffer_pool_dump_pct = 40
Innodb_undo_log_truncate = 1
Innodb_undo_tablespaces = 3
Innodb_max_undo_log_size = 1G
innodb_purge_rseg_truncate_frequency = 128
Binlog_gtid_simple_recovery=1
Log_timestamps=system
Show_compatibility_56=on
Sql_mode= ' Strict_trans_tables,no_zero_in_date,no_zero_date,error_for_division_by_zero,no_auto_create_user,no_ Engine_substitution '
7. Initialize the database
The version was mysql_install_db before 5.7.6.
Mysqld--initialize used after version 5.7.6
#################### #官网标注 #####################################
shell> bin/mysql_install_db--user=mysql # mysql 5.7.5
shell> bin/mysqld--initialize--user=mysql # mysql 5.7.6 and up
shell> bin/mysql_ssl_rsa_setup # mysql 5.7.6 and up
#################### #官网标注 #####################################
/usr/local/mysql/bin/mysqld--initialize--user=mysql--datadir=/data/mysql/data--basedir=/usr/local/mysql
There may be insufficient memory error, self-tuning to adjust the buffer size on the line
/usr/local/mysql/bin/mysql_ssl_rsa_setup
There is no print log, temporary password can not be used, had to crack, there are methods behind.
8. Start the database
Vim/usr/local/mysql/support-files/mysql.server
Plus absolute path
Basedir=/usr/local/mysql
Datadir=/data/mysql/data
Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld
Service mysqld Start
9. Configure Environment variables
Vim/etc/profile
Export Path=/usr/local/mysql/bin: $PATH
Source/etc/profile
10, check the MySQL temporary password, this I do not need, not so, directly cracked.
Cat/root/.mysql_secret
Mysql-uroot-p ' Cat/root/.mysql_secret '
If can go in, basically to this cut off, can normal use.
* * Cannot log in normally, use temporary password cannot wait to enter * *
11. Crack Password
Mysqld_safe--defaults-file=/usr/local/mysql/etc/my.cnf--skip-grant-tables--skip-networking&
Update Mysql.user set Authentication_string=password (' 123456 ') where user= ' root ';
11.1, find the process number, kill the MySQL process
PS aux | grep MySQL
Kill-9 PID
Service mysqld Start
11.2. Log in to MySQL
Mysql-u root-p ' password '
Prompt to change Password:
mysql> alter user [email protected] identified by ' 123456 ';
Okay, OK.
This article is from the "LINUX" blog, so be sure to keep this source http://wangpengtai.blog.51cto.com/3882831/1919995
CentOS6.9 Compiling and installing MySQL5.7.16