Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand TiDB compatible MySQL parameter optimization

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to understand TiDB compatible MySQL parameter optimization". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The default SQL mode is the same as MySQL

Both TiDB and MySQL 5.7are ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Currently:

Mysql > SELECT @ @ sql_mode

->

+-- +

| | @ @ sql_mode |

+-- +

| | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |

+-- +

1 row in set (0.00 sec)

Mysql >

SET [SESSION | GLOBAL] sql_mode='modes' `

SET GLOBAL sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

Tidb

Set the maximum connection:

Set global max_user_connections=200

Mysql > show variables like'% conn%'

+-+ +

| | Variable_name | Value |

+-+ +

| | performance_schema_session_connect_attrs_size | 512 | |

| | disconnect_on_expired_password | 1 | |

| | collation_connection | utf8_general_ci |

| | character_set_connection | utf8 |

| | connect_timeout | 10 | |

| | max_user_connections | 0 | |

| | max_connections | 151 | |

| | init_connect |

| | max_connect_errors | 100 | |

+-+ +

9 rows in set (0.01 sec)

Mysql >

Mysql > show variables like'% log%'

+-+

| | Variable_name | Value |

+-+

| | relay_log_space_limit | 0 | |

| | ndb_table_no_logging |

| | relay_log_recovery | 0 | |

| | log_bin | 0 | |

| | innodb_mirrored_log_groups | 1 | |

| | innodb_log_buffer_size | 8388608 | |

| | log_slave_updates | 0 | |

| | log_error | / usr/local/mysql/data/localhost.err |

| | log_bin_use_v1_row_events | 0 | |

| | innodb_log_files_in_group | 2 | |

| | tidb_slow_log_threshold | 300 | |

| | binlog_gtid_simple_recovery | 1 | |

| | relay_log_info_file | relay-log.info |

| | back_log | 80 | |

| | tidb_general_log | 0 | |

| | innodb_log_file_size | 50331648 | |

| | innodb_api_enable_binlog | 0 | |

| | innodb_log_group_home_dir |. / | |

| | tidb_query_log_max_len | 2048 | |

| | log_output | FILE |

| | innodb_locks_unsafe_for_binlog | 0 | |

| | relay_log_info_repository | FILE |

| | innodb_undo_logs | 128 | |

| | binlog_checksum | CRC32 |

| | innodb_flush_log_at_timeout | 1 | |

| | slow_query_log_file | / usr/local/mysql/data/localhost-slow.log |

| | binlog_direct_non_transactional_updates | OFF |

| | innodb_online_alter_log_max_size | 134217728 | |

| | log_timestamps |

| | max_binlog_stmt_cache_size | 18446744073709547520 | |

| | innodb_log_compressed_pages | ON |

| | binlog_format | STATEMENT |

| | innodb_max_undo_log_size |

| | log_queries_not_using_indexes | OFF |

| | relay_log_purge | ON |

| | binlog_cache_size | 32768 | |

| | innodb_log_checksum_algorithm |

| | ndb_log_binlog_index |

| | max_binlog_cache_size | 18446744073709547520 | |

| | binlog_max_flush_queue_time | 0 | |

| | binlog_rows_query_log_events | OFF |

| | slow_query_log | OFF |

| | general_log | 0 | |

| | max_binlog_size | 1073741824 | |

| | binlog_stmt_cache_size | 32768 | |

| | sql_log_bin | 1 | |

| | general_log_file | / usr/local/mysql/data/localhost.log |

| | log_slow_slave_statements | OFF |

| | sql_log_off | OFF |

| | innodb_log_write_ahead_size |

| | log_backward_compatible_user_definitions |

| | log_syslog |

| | sync_binlog | 0 | |

| | binlog_group_commit_sync_delay |

| | log_syslog_include_pid |

| | binlog_order_commits | ON |

| | innodb_undo_log_truncate |

| | sync_relay_log_info | 10000 | |

| | log_error_verbosity |

| | log_warnings | 1 | |

| | log_syslog_facility |

| | binlogging_impossible_mode | IGNORE_ERROR |

| | ndb_log_updated_only |

| | ndb_log_empty_epochs |

| | binlog_group_commit_sync_no_delay_count |

| | innodb_flush_log_at_trx_commit | 1 | |

| | log_bin_trust_function_creators | OFF |

| | binlog_error_action | IGNORE_ERROR |

| | log_throttle_queries_not_using_indexes | 0 | |

| | max_relay_log_size | 0 | |

| | binlog_row_image | FULL |

| | sync_relay_log | 10000 | |

| | log_slow_admin_statements | OFF |

| | log_syslog_tag |

| | expire_logs_days | 0 | |

+-+

75 rows in set (0.01 sec)

Mysql >

Set global max_connections=1000; # this parameter requires db to be restarted

Restart is required after setting.

The parameter SET GLOBAL binlog_format = 'ROW'; # is dynamically modified

Restart the service:

Stop the tidb service:

Ansible-playbook stop.yml-tags=tidb

Start the tidb service:

Ansible-playbook start.yml-tags=tidb

"how to understand TiDB compatible MySQL parameter optimization" content is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report