Mysql5.7.11 source code deployment

Posted by jarv on Wed, 29 Jan 2020 17:40:38 +0100

Put a Mysql5.7.11 installation package address first
Link: https://pan.baidu.com/s/17FF4CkWSeknOgctyo4Cdxg
Extraction code: y891

[root@hadoop001 local]# rpm -qa|grep -i mysql uninstall if there are components
[root@hadoop001 local]# rpm -qa|grep -i mariadb uninstall if there are components
[root@hadoop001]# tar xzvf /root/cdh5.16.1/mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
[root@hadoop39 local]#cd /usr/local
[root@hadoop39 local]# mv mysql-5.7.11-linux-glibc2.5-x86_64 mysql
[root@hadoop001 local]# mkdir mysql/arch mysql/data mysql/tmp
//Change my.cnf file
vim /etc/my.cnf
[client]
port            = 3306
socket          = /usr/local/mysql/data/mysql.sock
default-character-set=utf8mb4

[mysqld]
port            = 3306
socket          = /usr/local/mysql/data/mysql.sock
character-set-server=utf8mb4
skip-slave-start
skip-external-locking
key_buffer_size = 256M
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 4M
query_cache_size= 32M
max_allowed_packet = 16M
myisam_sort_buffer_size=128M
tmp_table_size=32M
table_open_cache = 512
thread_cache_size = 8
wait_timeout = 86400
interactive_timeout = 86400
max_connections = 600
# Try number of CPU's*2 for thread_concurrency
#thread_concurrency = 32 
#isolation level and default engine 
default-storage-engine = INNODB
transaction-isolation = READ-COMMITTED
server-id  = 1739
basedir     = /usr/local/mysql
datadir     = /usr/local/mysql/data
pid-file     = /usr/local/mysql/data/hostname.pid
#open performance schema
log-warnings
sysdate-is-now
binlog_format = ROW
log_bin_trust_function_creators=1
log-error  = /usr/local/mysql/data/hostname.err
log-bin = /usr/local/mysql/arch/mysql-bin
expire_logs_days = 7
innodb_write_io_threads=16
relay-log  = /usr/local/mysql/relay_log/relay-log
relay-log-index = /usr/local/mysql/relay_log/relay-log.index
relay_log_info_file= /usr/local/mysql/relay_log/relay-log.info
log_slave_updates=1
gtid_mode=OFF
enforce_gtid_consistency=OFF
# slave
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=4
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=ON
#other logs
#general_log =1
#general_log_file  = /usr/local/mysql/data/general_log.err
#slow_query_log=1
#slow_query_log_file=/usr/local/mysql/data/slow_log.err
#for replication slave
sync_binlog = 500
#for innodb options 
innodb_data_home_dir = /usr/local/mysql/data/
innodb_data_file_path = ibdata1:1G;ibdata2:1G:autoextend
innodb_log_group_home_dir = /usr/local/mysql/arch
innodb_log_files_in_group = 4
innodb_log_file_size = 1G
innodb_log_buffer_size = 200M
#Adjust pool size according to production needs 
innodb_buffer_pool_size = 2G
#innodb_additional_mem_pool_size = 50M #deprecated in 5.6
tmpdir = /usr/local/mysql/tmp
innodb_lock_wait_timeout = 1000
#innodb_thread_concurrency = 0
innodb_flush_log_at_trx_commit = 2
innodb_locks_unsafe_for_binlog=1
#innodb io features: add for mysql5.5.8
performance_schema
innodb_read_io_threads=4
innodb-write-io-threads=4
innodb-io-capacity=200
#purge threads change default(0) to 1 for purge
innodb_purge_threads=1
innodb_use_native_aio=on
#case-sensitive file names and separate tablespace
innodb_file_per_table = 1
lower_case_table_names=1

[mysqldump]
quick
max_allowed_packet = 128M

[mysql]
no-auto-rehash
default-character-set=utf8mb4

[mysqlhotcopy]
interactive-timeout

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M



[root@hadoop001 local]# groupadd -g 101 dba
[root@hadoop001 local]# useradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin
[root@hadoop001 local]# cp /etc/skel/.* /usr/local/mysql
[root@hadoop001 local]# vi mysql/.bashrc
//Append:
export MYSQL_BASE=/usr/local/mysql
export PATH=${MYSQL_BASE}/bin:$PATH
unset USERNAME
#stty erase ^H
set umask to 022
umask 022
PS1=`uname -n`":"'$USER'":"'$PWD'":>"; export PS1
[root@hadoop001 local]# chown  mysqladmin:dba /etc/my.cnf 
[root@hadoop001 local]# chmod  640 /etc/my.cnf  
[root@hadoop001 local]# chown -R mysqladmin:dba /usr/local/mysql
[root@hadoop001 local]# chmod -R 755 /usr/local/mysql 
[root@hadoop001 local]# cd /usr/local/mysql
#Copy the service file to init.d and rename it to mysql
[root@hadoop001 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysql 
#Give executable permission
[root@hadoop001 mysql]# chmod +x /etc/rc.d/init.d/mysql
#Delete service
[root@hadoop001 mysql]# chkconfig --del mysql
#Add service
[root@hadoop001 mysql]# chkconfig --add mysql
[root@hadoop001 mysql]# chkconfig --level 345 mysql on
#Install libaio and initial db of mysql 
[root@hadoop39 mysql]# yum -y install libaio
[root@hadoop39 mysql]# sudo su - mysqladmin
hadoop001:mysqladmin:/usr/local/mysql:>bin/mysqld --defaults-file=/etc/my.cnf  --user=mysqladmin  --basedir=/usr/local/mysql/  --datadir=/usr/local/mysql/data/ --initialize
#To view a temporary password:
hadoop001:mysqladmin:/usr/local/mysql/data:>cat hostname.err |grep password    
//The result is as follows: 2019-10-16t11:07:21.328047z 1 [note] a temporary password is generated for root @ localhost: d5d & 5mj  
#start-up   	
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
#Login and change user password
mysql -uroot -p
alter user root@localhost identified by 'root123';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root123' ;
flush privileges;
#Restart mysql
hadoop001:mysqladmin:/usr/local/mysql/data:>service mysql restart

The default character set here is utfmb4. If there is any modification, you can directly modify the corresponding configuration options in the three upper [mysqld], [mysql] and [client].

ps: This version is also listed in this column for the vulnerabilities such as MySQL remote code execution. For the startup under root and the startup security under non root, I prefer to start under non root users, which is more in line with the needs of the current enterprise production environment. Unfortunately, this vulnerability exists under mysql5.7 series, that is to say, if you want to avoid this problem fundamentally, you must go to the 8 series version of my SQL, this is also a big hidden danger for the pursuit of stability rather than the latest production environment, so other means can be taken to protect this multiple vulnerabilities.

Published 5 original articles, praised 0, visited 88
Private letter follow

Topics: MySQL mysqladmin RPM Linux