mysql-5.7.25 二进制安装

######################################################### 二进制安装 #######################################################

[root@starsky ~]# wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
[root@starsky ~]# mkdir /data/mysql
[root@starsky ~]# tar -zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz -C /data/mysql
[root@starsky ~]# cd /data/mysql/
[root@starsky mysql]# ll
total 4
drwxr-xr-x 9 root root 4096 Jan 6 09:17 mysql-5.7.25-linux-glibc2.12-x86_64
[root@starsky mysql]# mv mysql-5.7.25-linux-glibc2.12-x86_64/ mysql-5.7.25
[root@starsky mysql]# ll
total 4
drwxr-xr-x 9 root root 4096 Jan 6 09:17 mysql-5.7.25
[root@starsky mysql]# cd mysql-5.7.25/
[root@starsky mysql-5.7.25]# ll
total 52
drwxr-xr-x 2 root root 4096 Jan 6 09:17 bin
-rw-r--r-- 1 7161 31415 17987 Dec 21 2018 COPYING
drwxr-xr-x 2 root root 4096 Jan 6 09:17 docs
drwxr-xr-x 3 root root 4096 Jan 6 09:17 include
drwxr-xr-x 5 root root 4096 Jan 6 09:17 lib
drwxr-xr-x 4 root root 4096 Jan 6 09:17 man
-rw-r--r-- 1 7161 31415 2478 Dec 21 2018 README
drwxr-xr-x 28 root root 4096 Jan 6 09:17 share
drwxr-xr-x 2 root root 4096 Jan 6 09:17 support-files
[root@starsky mysql-5.7.25]# mkdir data
[root@starsky mysql-5.7.25]# cp /mysql_8.0.19/my.cnf /data/mysql/mysql-5.7.25/
[root@starsky mysql-5.7.25]# chown -R mysql.mysql /data/mysql/mysql-5.7.25/
[root@starsky mysql-5.7.25]# ll
total 60
drwxr-xr-x 2 mysql mysql 4096 Jan 6 09:17 bin
-rw-r--r-- 1 mysql mysql 17987 Dec 21 2018 COPYING
drwxr-xr-x 2 mysql mysql 4096 Jan 6 09:21 data
drwxr-xr-x 2 mysql mysql 4096 Jan 6 09:17 docs
drwxr-xr-x 3 mysql mysql 4096 Jan 6 09:17 include
drwxr-xr-x 5 mysql mysql 4096 Jan 6 09:17 lib
drwxr-xr-x 4 mysql mysql 4096 Jan 6 09:17 man
-rw-r--r-- 1 mysql mysql 2382 Jan 6 09:21 my.cnf
-rw-r--r-- 1 mysql mysql 2478 Dec 21 2018 README
drwxr-xr-x 28 mysql mysql 4096 Jan 6 09:17 share
drwxr-xr-x 2 mysql mysql 4096 Jan 6 09:17 support-files
[root@starsky mysql-5.7.25]# ./bin/mysqld --defaults-file=/data/mysql/mysql-5.7.25/my.cnf --initialize --user=mysql
[root@starsky mysql-5.7.25]# ll data/
total 274484
-rw-r----- 1 mysql mysql 56 Jan 6 09:33 auto.cnf
-rw-r----- 1 mysql mysql 419 Jan 6 09:33 ib_buffer_pool
-rw-r----- 1 mysql mysql 12582912 Jan 6 09:33 ibdata1
-rw-r----- 1 mysql mysql 134217728 Jan 6 09:33 ib_logfile0
-rw-r----- 1 mysql mysql 134217728 Jan 6 09:33 ib_logfile1
drwxr-x--- 2 mysql mysql 4096 Jan 6 09:33 mysql
-rw-r----- 1 mysql mysql 177 Jan 6 09:33 mysql-bin.000001
-rw-r----- 1 mysql mysql 19 Jan 6 09:33 mysql-bin.index
-rw-r----- 1 mysql mysql 1839 Jan 6 09:33 mysql-error.log
-rw-r----- 1 mysql mysql 165 Jan 6 09:33 mysql-slow.log
drwxr-x--- 2 mysql mysql 4096 Jan 6 09:33 performance_schema
drwxr-x--- 2 mysql mysql 12288 Jan 6 09:33 sys
[root@starsky mysql-5.7.25]# less data/mysql-error.log | grep password | gawk ‘{print $NF}‘
>*&oa1A<er0#
[root@starsky mysql-5.7.25]# ./bin/mysqld_safe --defaults-file=/data/mysql/mysql-5.7.25/my.cnf --user=mysql &
[1] 32450
[root@starsky mysql-5.7.25]# 2021-01-06T01:33:56.820843Z mysqld_safe Logging to ‘/data/mysql/mysql-5.7.25/data/mysql-error.log‘.
2021-01-06T01:33:56.846176Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql-5.7.25/data
[root@starsky mysql-5.7.25]# ps -ef | grep mysql
mysql 971 32450 1 09:33 pts/0 00:00:00 /data/mysql/mysql-5.7.25/bin/mysqld --defaults-file=/data/mysql/mysql-5.7.25/my.cnf --basedir=/data/mysql/mysql-5.7.25 --datadir=/data/mysql/mysql-5.7.25/data --plugin-dir=/data/mysql/mysql-5.7.25/lib/plugin --user=mysql --log-error=mysql-error.log --open-files-limit=65535 --pid-file=mysqld.pid --socket=mysqld.sock --port=3306
root 1057 22899 0 09:34 pts/0 00:00:00 grep --color=auto mysql
root 3914 1 0 2020 ? 00:00:00 /bin/sh /prometheus-2.22.0/prometheus_exporter/mysqld_exporter-0.12.1/mysqld_exporter_start.sh
root 3915 3914 0 2020 ? 02:24:32 ./mysqld_exporter --config.my-cnf=my.cnf
mysql 24797 1 0 Jan04 ? 00:25:20 /mysql_8.0.19/bin/mysqld --defaults-file=/mysql_8.0.19/my.cnf --daemonize --pid-file=/mysql_8.0.19/data/mysqd.pid --user=mysql --port=3307
root 32450 22899 0 09:33 pts/0 00:00:00 /bin/sh ./bin/mysqld_safe --defaults-file=/data/mysql/mysql-5.7.25/my.cnf
[root@starsky mysql-5.7.25]#
[root@starsky mysql-5.7.25]# ./bin/mysql -uroot -p -S /data/mysql/mysql-5.7.25/data/mysqld.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25-log

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> set password=password(‘tanwensi‘);
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> create user ‘root‘@‘%‘ identified by ‘tanwensi‘;
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on *.* to ‘root‘@‘%‘ with grant options;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘options‘ at line 1
mysql>
mysql> grant all on *.* to ‘root‘@‘%‘ with grant option;
Query OK, 0 rows affected (0.01 sec)

mysql> \q
Bye
[root@starsky mysql-5.7.25]# ./bin/mysql -uroot -p -S /data/mysql/mysql-5.7.25/data/mysqld.sock

 


########################################################### 安装打包好的数据库  ######################################################
创建 mysql 用户组
tar -zxvf mysql-5.7.25.tar.gz -C /data/
cd /data/mysql/mysql-5.7.25/ && ./bin/mysqld --defaults-file=/data/mysql/mysql-5.7.25/my.cnf --user=mysql &
mysql -uroot -pstarsky -S /data/mysql/mysql-5.7.25/data/mysqld.sock

 


########################################################### 配置文件  ######################################################
[root@starsky data]# cat /data/mysql/mysql-5.7.25/my.cnf
[mysqld]
# 常规
port = 3306
server_id = 1
basedir = /data/mysql/mysql-5.7.25
datadir = /data/mysql/mysql-5.7.25/data
log_bin = mysql-bin
relay_log = mysql-relay
log_error = mysql-error.log

# BINLOG
binlog_error_action = ABORT_SERVER
binlog_format = row
binlog_rows_query_log_events = 1
log_slave_updates = 1
master_info_repository = TABLE
max_binlog_size = 128M
relay_log_info_repository = TABLE
relay_log_recovery = 1
sync_binlog = 1

# GTID #
gtid_mode = ON
enforce_gtid_consistency = 1

# ENGINE
default_storage_engine = InnoDB
innodb_buffer_pool_size = 128M
innodb_data_file_path = ibdata1:12M:autoextend
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit=1
innodb_io_capacity = 500
innodb_log_buffer_size = 64M
innodb_log_file_size = 128M
innodb_log_files_in_group = 2
innodb_max_dirty_pages_pct = 60
innodb_print_all_deadlocks=1
innodb_stats_on_metadata = 0
innodb_strict_mode = 1
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_purge_threads = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_buffer_pool_dump_pct=25
innodb_sort_buffer_size = 8M

# CACHE
key_buffer_size = 8M
tmp_table_size = 8M
max_heap_table_size = 8M
table_open_cache = 1024
max_connections = 2000
thread_cache_size = 1024
open_files_limit = 65535
binlog_cache_size = 1M
join_buffer_size = 8M
sort_buffer_size = 8M

# SLOW LOG
slow_query_log = 1
slow_query_log_file = mysql-slow.log
log_slow_admin_statements = 1
log_slow_slave_statements = 1
long_query_time = 1

# Semi sync Config
loose_plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
loose_rpl_semi_sync_master_enabled = 1
loose_rpl_semi_sync_slave_enabled = 0
loose_rpl_semi_sync_master_timeout = 30000
loose_rpl_semi_sync_master_wait_for_slave_count = 1
loose_rpl_semi_sync_master_wait_no_slave = 0

# MISC
log_timestamps=SYSTEM
lower_case_table_names = 1
max_allowed_packet = 1G
read_only = 0
skip_external_locking = 1
skip_name_resolve = 1
skip_slave_start = 1
socket = mysqld.sock
pid_file = mysqld.pid
# disabled_storage_engines = ARCHIVE,BLACKHOLE,EXAMPLE,FEDERATED,MEMORY,MERGE,NDB
log-output = TABLE,FILE
character_set_server = utf8mb4
performance-schema-instrument=‘wait\lock\metadata\sql\mdl=ON‘

# MTS
slave-parallel-type=LOGICAL_CLOCK
slave_parallel_workers=16
slave_preserve_commit_order=1

mysql-5.7.25 二进制安装

上一篇:iframe嵌套findBI报错拒绝访问


下一篇:MySql版本升级(8.0.19升级到8.0.22)