Hướng dẫn show user variables mysql - hiển thị các biến người dùng mysql

13.7.7.41 & NBSP; Hiển thị câu lệnh Biến

SHOW [GLOBAL | SESSION] VARIABLES [LIKE 'pattern' | WHERE expr]

SHOW VARIABLES hiển thị các giá trị của các biến hệ thống MySQL (xem Phần & NBSP; 5.1.8, các biến hệ thống máy chủ của Hồi giáo). Tuyên bố này không yêu cầu bất kỳ đặc quyền. Nó chỉ đòi hỏi khả năng kết nối với máy chủ.

Thông tin biến hệ thống cũng có sẵn từ các nguồn này:

  • Bảng lược đồ hiệu suất. Xem Phần & NBSP; 27.12.14, Biến số hệ thống Lược đồ hiệu suất.

  • Lệnh biến MySQLadmin. Xem Phần & NBSP; 4.5.2, MySqladmin - Chương trình quản trị máy chủ MySQL.mysqladmin variables command. See Section 4.5.2, “mysqladmin — A MySQL Server Administration Program”.

Đối với SHOW VARIABLES, một mệnh đề LIKE, nếu có, chỉ ra tên biến nào phù hợp. Có thể đưa ra một điều khoản WHERE để chọn các hàng bằng cách sử dụng các điều kiện chung hơn, như được thảo luận trong Phần & NBSP; 26.8, Phần mở rộng để hiển thị các câu lệnh.

SHOW VARIABLES Chấp nhận tùy chọn SELECT @@GLOBAL.innodb_data_file_path;0 hoặc SELECT @@GLOBAL.innodb_data_file_path;1 Công cụ sửa đổi phạm vi biến đổi:

  • Với công cụ sửa đổi SELECT @@GLOBAL.innodb_data_file_path;0, câu lệnh hiển thị các giá trị biến hệ thống toàn cầu. Đây là các giá trị được sử dụng để khởi tạo các biến phiên tương ứng cho các kết nối mới với MySQL. Nếu một biến không có giá trị toàn cầu, không có giá trị nào được hiển thị.

  • Với công cụ sửa đổi SELECT @@GLOBAL.innodb_data_file_path;1, câu lệnh hiển thị các giá trị biến hệ thống có hiệu lực cho kết nối hiện tại. Nếu một biến không có giá trị phiên, giá trị toàn cầu được hiển thị. SELECT @@GLOBAL.innodb_data_file_path;4 là một từ đồng nghĩa với SELECT @@GLOBAL.innodb_data_file_path;1.

  • Nếu không có công cụ sửa đổi, mặc định là SELECT @@GLOBAL.innodb_data_file_path;1.

Phạm vi cho từng biến hệ thống được liệt kê tại Phần & NBSP; 5.1.8, các biến hệ thống máy chủ của Cameron.

SHOW VARIABLES phải tuân theo giới hạn chiều rộng hiển thị phụ thuộc phiên bản. Đối với các biến có các giá trị rất dài không được hiển thị hoàn toàn, hãy sử dụng SELECT @@GLOBAL.innodb_data_file_path;8 như một cách giải quyết. Ví dụ:

SELECT @@GLOBAL.innodb_data_file_path;

Hầu hết các biến hệ thống có thể được đặt tại khởi động máy chủ (các biến chỉ đọc như SELECT @@GLOBAL.innodb_data_file_path;9 là ngoại lệ). Nhiều người có thể được thay đổi trong thời gian chạy với câu lệnh mysql> SHOW VARIABLES; +--------------------------------------------+------------------------------+ | Variable_name | Value | +--------------------------------------------+------------------------------+ | activate_all_roles_on_login | OFF | | auto_generate_certs | ON | | auto_increment_increment | 1 | | auto_increment_offset | 1 | | autocommit | ON | | automatic_sp_privileges | ON | | avoid_temporal_upgrade | OFF | | back_log | 151 | | basedir | /usr/ | | big_tables | OFF | | bind_address | * | | binlog_cache_size | 32768 | | binlog_checksum | CRC32 | | binlog_direct_non_transactional_updates | OFF | | binlog_error_action | ABORT_SERVER | | binlog_expire_logs_seconds | 2592000 | | binlog_format | ROW | | binlog_group_commit_sync_delay | 0 | | binlog_group_commit_sync_no_delay_count | 0 | | binlog_gtid_simple_recovery | ON | | binlog_max_flush_queue_time | 0 | | binlog_order_commits | ON | | binlog_row_image | FULL | | binlog_row_metadata | MINIMAL | | binlog_row_value_options | | | binlog_rows_query_log_events | OFF | | binlog_stmt_cache_size | 32768 | | binlog_transaction_dependency_history_size | 25000 | | binlog_transaction_dependency_tracking | COMMIT_ORDER | | block_encryption_mode | aes-128-ecb | | bulk_insert_buffer_size | 8388608 | ... | max_allowed_packet | 67108864 | | max_binlog_cache_size | 18446744073709547520 | | max_binlog_size | 1073741824 | | max_binlog_stmt_cache_size | 18446744073709547520 | | max_connect_errors | 100 | | max_connections | 151 | | max_delayed_threads | 20 | | max_digest_length | 1024 | | max_error_count | 1024 | | max_execution_time | 0 | | max_heap_table_size | 16777216 | | max_insert_delayed_threads | 20 | | max_join_size | 18446744073709551615 | ... | thread_handling | one-thread-per-connection | | thread_stack | 286720 | | time_zone | SYSTEM | | timestamp | 1530906638.765316 | | tls_version | TLSv1.2,TLSv1.3 | | tmp_table_size | 16777216 | | tmpdir | /tmp | | transaction_alloc_block_size | 8192 | | transaction_allow_batching | OFF | | transaction_isolation | REPEATABLE-READ | | transaction_prealloc_size | 4096 | | transaction_read_only | OFF | | transaction_write_set_extraction | XXHASH64 | | unique_checks | ON | | updatable_views_with_limit | YES | | version | 8.0.12 | | version_comment | MySQL Community Server - GPL | | version_compile_machine | x86_64 | | version_compile_os | Linux | | version_compile_zlib | 1.2.11 | | wait_timeout | 28800 | | warning_count | 0 | | windowing_use_high_precision | ON | +--------------------------------------------+------------------------------+0. Xem Phần & NBSP; 5.1.9, Sử dụng các biến hệ thống, và Phần & NBSP; 13.7.6.1, Set Set Cú pháp để gán biến.

Đầu ra một phần được hiển thị ở đây. Danh sách các tên và giá trị có thể khác nhau cho máy chủ của bạn. Phần & NBSP; 5.1.8, Biến hệ thống máy chủ, mô tả ý nghĩa của từng biến và Phần & NBSP; 5.1.1, Định cấu hình máy chủ, cung cấp thông tin về việc điều chỉnh chúng.

mysql> SHOW VARIABLES; +--------------------------------------------+------------------------------+ | Variable_name | Value | +--------------------------------------------+------------------------------+ | activate_all_roles_on_login | OFF | | auto_generate_certs | ON | | auto_increment_increment | 1 | | auto_increment_offset | 1 | | autocommit | ON | | automatic_sp_privileges | ON | | avoid_temporal_upgrade | OFF | | back_log | 151 | | basedir | /usr/ | | big_tables | OFF | | bind_address | * | | binlog_cache_size | 32768 | | binlog_checksum | CRC32 | | binlog_direct_non_transactional_updates | OFF | | binlog_error_action | ABORT_SERVER | | binlog_expire_logs_seconds | 2592000 | | binlog_format | ROW | | binlog_group_commit_sync_delay | 0 | | binlog_group_commit_sync_no_delay_count | 0 | | binlog_gtid_simple_recovery | ON | | binlog_max_flush_queue_time | 0 | | binlog_order_commits | ON | | binlog_row_image | FULL | | binlog_row_metadata | MINIMAL | | binlog_row_value_options | | | binlog_rows_query_log_events | OFF | | binlog_stmt_cache_size | 32768 | | binlog_transaction_dependency_history_size | 25000 | | binlog_transaction_dependency_tracking | COMMIT_ORDER | | block_encryption_mode | aes-128-ecb | | bulk_insert_buffer_size | 8388608 | ... | max_allowed_packet | 67108864 | | max_binlog_cache_size | 18446744073709547520 | | max_binlog_size | 1073741824 | | max_binlog_stmt_cache_size | 18446744073709547520 | | max_connect_errors | 100 | | max_connections | 151 | | max_delayed_threads | 20 | | max_digest_length | 1024 | | max_error_count | 1024 | | max_execution_time | 0 | | max_heap_table_size | 16777216 | | max_insert_delayed_threads | 20 | | max_join_size | 18446744073709551615 | ... | thread_handling | one-thread-per-connection | | thread_stack | 286720 | | time_zone | SYSTEM | | timestamp | 1530906638.765316 | | tls_version | TLSv1.2,TLSv1.3 | | tmp_table_size | 16777216 | | tmpdir | /tmp | | transaction_alloc_block_size | 8192 | | transaction_allow_batching | OFF | | transaction_isolation | REPEATABLE-READ | | transaction_prealloc_size | 4096 | | transaction_read_only | OFF | | transaction_write_set_extraction | XXHASH64 | | unique_checks | ON | | updatable_views_with_limit | YES | | version | 8.0.12 | | version_comment | MySQL Community Server - GPL | | version_compile_machine | x86_64 | | version_compile_os | Linux | | version_compile_zlib | 1.2.11 | | wait_timeout | 28800 | | warning_count | 0 | | windowing_use_high_precision | ON | +--------------------------------------------+------------------------------+

Với mệnh đề LIKE, câu lệnh chỉ hiển thị các hàng cho các biến đó có tên khớp với mẫu. Để có được hàng cho một biến cụ thể, hãy sử dụng mệnh đề LIKE như được hiển thị:

SHOW VARIABLES LIKE 'max_join_size'; SHOW SESSION VARIABLES LIKE 'max_join_size';

Để có được danh sách các biến có tên khớp với mẫu, hãy sử dụng ký tự đại diện mysql> SHOW VARIABLES; +--------------------------------------------+------------------------------+ | Variable_name | Value | +--------------------------------------------+------------------------------+ | activate_all_roles_on_login | OFF | | auto_generate_certs | ON | | auto_increment_increment | 1 | | auto_increment_offset | 1 | | autocommit | ON | | automatic_sp_privileges | ON | | avoid_temporal_upgrade | OFF | | back_log | 151 | | basedir | /usr/ | | big_tables | OFF | | bind_address | * | | binlog_cache_size | 32768 | | binlog_checksum | CRC32 | | binlog_direct_non_transactional_updates | OFF | | binlog_error_action | ABORT_SERVER | | binlog_expire_logs_seconds | 2592000 | | binlog_format | ROW | | binlog_group_commit_sync_delay | 0 | | binlog_group_commit_sync_no_delay_count | 0 | | binlog_gtid_simple_recovery | ON | | binlog_max_flush_queue_time | 0 | | binlog_order_commits | ON | | binlog_row_image | FULL | | binlog_row_metadata | MINIMAL | | binlog_row_value_options | | | binlog_rows_query_log_events | OFF | | binlog_stmt_cache_size | 32768 | | binlog_transaction_dependency_history_size | 25000 | | binlog_transaction_dependency_tracking | COMMIT_ORDER | | block_encryption_mode | aes-128-ecb | | bulk_insert_buffer_size | 8388608 | ... | max_allowed_packet | 67108864 | | max_binlog_cache_size | 18446744073709547520 | | max_binlog_size | 1073741824 | | max_binlog_stmt_cache_size | 18446744073709547520 | | max_connect_errors | 100 | | max_connections | 151 | | max_delayed_threads | 20 | | max_digest_length | 1024 | | max_error_count | 1024 | | max_execution_time | 0 | | max_heap_table_size | 16777216 | | max_insert_delayed_threads | 20 | | max_join_size | 18446744073709551615 | ... | thread_handling | one-thread-per-connection | | thread_stack | 286720 | | time_zone | SYSTEM | | timestamp | 1530906638.765316 | | tls_version | TLSv1.2,TLSv1.3 | | tmp_table_size | 16777216 | | tmpdir | /tmp | | transaction_alloc_block_size | 8192 | | transaction_allow_batching | OFF | | transaction_isolation | REPEATABLE-READ | | transaction_prealloc_size | 4096 | | transaction_read_only | OFF | | transaction_write_set_extraction | XXHASH64 | | unique_checks | ON | | updatable_views_with_limit | YES | | version | 8.0.12 | | version_comment | MySQL Community Server - GPL | | version_compile_machine | x86_64 | | version_compile_os | Linux | | version_compile_zlib | 1.2.11 | | wait_timeout | 28800 | | warning_count | 0 | | windowing_use_high_precision | ON | +--------------------------------------------+------------------------------+3 trong mệnh đề LIKE:

SHOW VARIABLES LIKE '%size%'; SHOW GLOBAL VARIABLES LIKE '%size%';

Các ký tự ký tự đại diện có thể được sử dụng ở bất kỳ vị trí nào trong mẫu để được khớp. Nói đúng ra, bởi vì mysql> SHOW VARIABLES; +--------------------------------------------+------------------------------+ | Variable_name | Value | +--------------------------------------------+------------------------------+ | activate_all_roles_on_login | OFF | | auto_generate_certs | ON | | auto_increment_increment | 1 | | auto_increment_offset | 1 | | autocommit | ON | | automatic_sp_privileges | ON | | avoid_temporal_upgrade | OFF | | back_log | 151 | | basedir | /usr/ | | big_tables | OFF | | bind_address | * | | binlog_cache_size | 32768 | | binlog_checksum | CRC32 | | binlog_direct_non_transactional_updates | OFF | | binlog_error_action | ABORT_SERVER | | binlog_expire_logs_seconds | 2592000 | | binlog_format | ROW | | binlog_group_commit_sync_delay | 0 | | binlog_group_commit_sync_no_delay_count | 0 | | binlog_gtid_simple_recovery | ON | | binlog_max_flush_queue_time | 0 | | binlog_order_commits | ON | | binlog_row_image | FULL | | binlog_row_metadata | MINIMAL | | binlog_row_value_options | | | binlog_rows_query_log_events | OFF | | binlog_stmt_cache_size | 32768 | | binlog_transaction_dependency_history_size | 25000 | | binlog_transaction_dependency_tracking | COMMIT_ORDER | | block_encryption_mode | aes-128-ecb | | bulk_insert_buffer_size | 8388608 | ... | max_allowed_packet | 67108864 | | max_binlog_cache_size | 18446744073709547520 | | max_binlog_size | 1073741824 | | max_binlog_stmt_cache_size | 18446744073709547520 | | max_connect_errors | 100 | | max_connections | 151 | | max_delayed_threads | 20 | | max_digest_length | 1024 | | max_error_count | 1024 | | max_execution_time | 0 | | max_heap_table_size | 16777216 | | max_insert_delayed_threads | 20 | | max_join_size | 18446744073709551615 | ... | thread_handling | one-thread-per-connection | | thread_stack | 286720 | | time_zone | SYSTEM | | timestamp | 1530906638.765316 | | tls_version | TLSv1.2,TLSv1.3 | | tmp_table_size | 16777216 | | tmpdir | /tmp | | transaction_alloc_block_size | 8192 | | transaction_allow_batching | OFF | | transaction_isolation | REPEATABLE-READ | | transaction_prealloc_size | 4096 | | transaction_read_only | OFF | | transaction_write_set_extraction | XXHASH64 | | unique_checks | ON | | updatable_views_with_limit | YES | | version | 8.0.12 | | version_comment | MySQL Community Server - GPL | | version_compile_machine | x86_64 | | version_compile_os | Linux | | version_compile_zlib | 1.2.11 | | wait_timeout | 28800 | | warning_count | 0 | | windowing_use_high_precision | ON | +--------------------------------------------+------------------------------+5 là một ký tự đại diện phù hợp với bất kỳ nhân vật nào, bạn nên thoát nó dưới dạng mysql> SHOW VARIABLES; +--------------------------------------------+------------------------------+ | Variable_name | Value | +--------------------------------------------+------------------------------+ | activate_all_roles_on_login | OFF | | auto_generate_certs | ON | | auto_increment_increment | 1 | | auto_increment_offset | 1 | | autocommit | ON | | automatic_sp_privileges | ON | | avoid_temporal_upgrade | OFF | | back_log | 151 | | basedir | /usr/ | | big_tables | OFF | | bind_address | * | | binlog_cache_size | 32768 | | binlog_checksum | CRC32 | | binlog_direct_non_transactional_updates | OFF | | binlog_error_action | ABORT_SERVER | | binlog_expire_logs_seconds | 2592000 | | binlog_format | ROW | | binlog_group_commit_sync_delay | 0 | | binlog_group_commit_sync_no_delay_count | 0 | | binlog_gtid_simple_recovery | ON | | binlog_max_flush_queue_time | 0 | | binlog_order_commits | ON | | binlog_row_image | FULL | | binlog_row_metadata | MINIMAL | | binlog_row_value_options | | | binlog_rows_query_log_events | OFF | | binlog_stmt_cache_size | 32768 | | binlog_transaction_dependency_history_size | 25000 | | binlog_transaction_dependency_tracking | COMMIT_ORDER | | block_encryption_mode | aes-128-ecb | | bulk_insert_buffer_size | 8388608 | ... | max_allowed_packet | 67108864 | | max_binlog_cache_size | 18446744073709547520 | | max_binlog_size | 1073741824 | | max_binlog_stmt_cache_size | 18446744073709547520 | | max_connect_errors | 100 | | max_connections | 151 | | max_delayed_threads | 20 | | max_digest_length | 1024 | | max_error_count | 1024 | | max_execution_time | 0 | | max_heap_table_size | 16777216 | | max_insert_delayed_threads | 20 | | max_join_size | 18446744073709551615 | ... | thread_handling | one-thread-per-connection | | thread_stack | 286720 | | time_zone | SYSTEM | | timestamp | 1530906638.765316 | | tls_version | TLSv1.2,TLSv1.3 | | tmp_table_size | 16777216 | | tmpdir | /tmp | | transaction_alloc_block_size | 8192 | | transaction_allow_batching | OFF | | transaction_isolation | REPEATABLE-READ | | transaction_prealloc_size | 4096 | | transaction_read_only | OFF | | transaction_write_set_extraction | XXHASH64 | | unique_checks | ON | | updatable_views_with_limit | YES | | version | 8.0.12 | | version_comment | MySQL Community Server - GPL | | version_compile_machine | x86_64 | | version_compile_os | Linux | | version_compile_zlib | 1.2.11 | | wait_timeout | 28800 | | warning_count | 0 | | windowing_use_high_precision | ON | +--------------------------------------------+------------------------------+6 để phù hợp với nó theo nghĩa đen. Trong thực tế, điều này hiếm khi cần thiết.

Chủ đề