1. 介质下载
www.mysql.com -> downloads -> MySQL Community(GPL) Downloads
-> Download Archives -> MySQL Community Server
2.安装rpm包
–镜像默认已安装—
yum install make
yum install gcc
yum install ncurses
yum install zlib
yum install openssl
yum install libxml2
—需安装—
yum install cmake
yum install openssl-devel
yum install ncurses-devel
yum install bison
yum install gcc-c++
3.cmake编译安装
(1)准备
mkdir -p /u01/patch
useradd mysql
cd /u01/patch/
tar -zxvf mysql-5.7.33.tar.gz
tar -zxvf mysql-boost-5.7.33.tar.gz
(2)编译
排版原因没有斜杠
cd /u01/patch/mysql-5.7.33
cmake
-DCMAKE_INSTALL_PREFIX=/u01/mysql3306
-DMYSQL_DATADIR=/u01/mysql3306/data
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=all
-DWITH_SSL=yes
-DWITH_EMBEDDED_SERVER=1
-DENABLED_LOCAL_INFILE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DMYSQL_UNIX_ADDR=/u01/mysql3306/run/mysql.sock
-DMYSQL_TCP_PORT=3306
-DSYSCONFDIR=/etc
-DWITH_READLINE=on
-DDOWNLOAD_BOOST=1
-DWITH_BOOST=/u01/patch/mysql-5.7.33/boost
cd /u01/patch/mysql-5.7.33
make
(3)安装
mkdir -p /u01/mysql3306/data
mkdir -p /u01/mysql3306/log/iblog
mkdir -p /u01/mysql3306/log/binlog
mkdir -p /u01/mysql3306/run
mkdir -p /u01/mysql3306/tmp
make install
4.mysql初始化,启动
chown -R mysql:mysql /u01
chmod -R 775 /u01
su - mysql
vi .bash_profile
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/u01/mysql3306/bin
(1)初始化
/u01/mysql3306/bin/mysqld --initialize --user=mysql --datadir=/u01/mysql3306/data --basedir=/u01/mysql3306
(2)启动
vi /u01/mysql3306/my.cnf
[client]
port=3306
socket=/u01/mysql3306/run/mysql.sock
default-character-set=utf8
[mysql]
no-auto-rehash
default-character-set=utf8
[mysqld]
port=3306
character-set-server=utf8
socket=/u01/mysql3306/run/mysql.sock
basedir=/u01/mysql3306
datadir=/u01/mysql3306/data
explicit_defaults_for_timestamp=true
lower_case_table_names=1
back_log=103
max_connections=3000
max_connect_errors=100000
table_open_cache=512
external-locking=FALSE
max_allowed_packet=32M
sort_buffer_size=2M
join_buffer_size=2M
thread_cache_size=51
query_cache_size=32M
#query_cache_limit=4M
transaction_isolation=REPEATABLE-READ
tmp_table_size=96M
max_heap_table_size=96M
###***slowqueryparameters
long_query_time=1
slow_query_log = 1
slow_query_log_file=/u01/mysql3306/log/slow.log
###***binlogparameters
log-bin=mysql-bin
binlog_cache_size=4M
max_binlog_cache_size=4096M
max_binlog_size=1024M
binlog_format=MIXED
expire_logs_days=7
###***relay-logparameters
#relay-log=/data/3307/relay-bin
#relay-log-info-file=/data/3307/relay-log.info
#master-info-repository=table
#relay-log-info-repository=table
#relay-log-recovery=1
#***MyISAMparameters
key_buffer_size=16M
read_buffer_size=1M
read_rnd_buffer_size=16M
bulk_insert_buffer_size=1M
#skip-name-resolve
###***master-slavereplicationparameters
server-id=3306
#slave-skip-errors=all
#***Innodbstorageengineparameters
innodb_buffer_pool_size=512M
innodb_data_file_path=ibdata1:10M:autoextend
#innodb_file_io_threads=8
innodb_thread_concurrency=16
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=16M
innodb_log_file_size=512M
innodb_log_files_in_group=2
innodb_max_dirty_pages_pct=75
innodb_buffer_pool_dump_pct=50
innodb_lock_wait_timeout=50
innodb_file_per_table=on
[mysqldump]
quick
max_allowed_packet=32M
[myisamchk]
key_buffer=16M
sort_buffer_size=16M
read_buffer=8M
write_buffer=8M
[mysqld_safe]
open-files-limit=8192
log-error=/u01/mysql3306/log/error.log
pid-file=/u01/mysql3306/run/mysqld.pid
nohup /u01/mysql3306/bin/mysqld_safe --defaults-file=/u01/mysql3306/my.cnf --user=mysql > /u01/mysql3306/log/start_stop.log 2>&1 &
—defaults-file必须是第二个参数,否则报错,bug
(3)首次登陆
mysql -uroot -p
Enter password: ZhuauX&(r3mb