MySQL中show命令的用法详解(mysql中show的)
MySQL中show命令的用法详解
MySQL是一种开放源代码的关系型数据库管理系统,它被广泛应用于各种网站和企业中。在MySQL中,我们可以使用show命令来查看数据库、表、用户以及变量等信息。在本文中,我们将详细介绍show命令的用法,并用示例代码来演示其使用方法。
1. 查看数据库
我们可以使用show命令来查看当前MySQL数据库中所有的数据库。只需在MySQL终端输入以下命令即可:
show databases;
这条命令将在终端中显示所有的数据库名称,如下所示:
+--------------------+
| Database |+--------------------+
| information_schema || mysql |
| performance_schema || sakila |
| sys || world |
+--------------------+
2. 查看表
在MySQL中,我们可以使用show命令来查看指定数据库中的所有表。只需在MySQL终端输入以下命令即可:
show tables from [database_name];
其中,[database_name]是你想要查看表的数据库名称。如果你想要查看所有数据库中的所有表,可以省略from关键字。示例代码如下:
show tables from sakila;
这条命令将在终端中显示指定数据库中的所有表名称,如下所示:
+----------------------------+
| Tables_in_sakila |+----------------------------+
| actor || actor_info |
| address || category |
| city || country |
| customer || customer_list |
| film || film_actor |
| film_category || film_list |
| film_text || inventory |
| language || nicetoseeyou |
| payment || rental |
| sales_by_film_category || sales_by_store |
| staff || staff_list |
| student_info || student_registration |
| student_system_check || student_system_check_qinay |
| student_system_check_zh || student_test |
| student_test_database || student_test_qinay |
| student_test_zh || student_user |
| student_user_check || student_user_test |
| student_zh_user_check || subject |
| supplier || title |
| user |+----------------------------+
3. 查看用户
在MySQL中,我们可以使用show命令来查看当前数据库中的所有用户。只需在MySQL终端输入以下命令即可:
show users;
这条命令将在终端中显示当前数据库中的所有用户信息,如下所示:
+------------------+-----------+
| user | host |+------------------+-----------+
| root | localhost || mysql.session | localhost |
| mysql.sys | localhost || debian-sys-mnt | localhost |
+------------------+-----------+
4. 查看变量
在MySQL中,我们可以使用show命令来查看当前数据库中的所有变量信息。只需在MySQL终端输入以下命令即可:
show variables;
这条命令将在终端中显示当前数据库中的所有变量及其值,如下所示:
+----------------------------------------------------+------------------------------------------------+
| Variable_name | Value |+----------------------------------------------------+------------------------------------------------+
| auto_generate_certs | ON || auto_increment_increment | 1 |
| auto_increment_offset | 1 || autocommit | ON |
| automatic_sp_privileges | ON || avoid_temporal_upgrade | OFF |
| back_log | 80 || basedir | /usr/ |
| binlog_cache_size | 32768 || binlog_checksum | CRC32 |
| binlog_direct_non_transactional_updates | OFF || binlog_error_action | ABORT_SERVER |
| 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_rotate_encryption_master_key_at_startup | OFF || binlog_row_event_max_size | 8192 |
| binlog_row_image | FULL || 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-cbc |
| bulk_insert_buffer_size | 8388608 || character_set_client | utf8 |
| character_set_connection | utf8 || character_set_database | utf8mb4 |
| character_set_filesystem | binary || character_set_results | utf8 |
| character_set_server | utf8mb4 || character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql-8.0/charsets/ || check_proxy_users | OFF |
| collation_connection | utf8_general_ci || collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci || completion_type | NO_CHN |
| concurrent_insert | AUTO || connect_timeout | 10 |
| core_file | OFF || datadir | /var/lib/mysql/ |
| date_format | %Y-%m-%d || datetime_format | %Y-%m-%d %H:%i:%s |
| debug_check_constrnts | OFF || debug_no_ha_panic | OFF |
| debug_sync | OFF || debug_sync_timeout | 0 |
| default_authentication_plugin | caching_sha2_password || default_password_lifetime | 0 |
| default_storage_engine | InnoDB || default_table_encryption | OFF |
| default_tmp_storage_engine | InnoDB || default_week_format | 0 |
| delay_key_write | ON || delayed_insert_limit | 100 |
| delayed_insert_timeout | 300 || delayed_queue_size | 1000 |
| disabled_storage_engines | || disconnect_on_expired_password | ON |
| div_precision_increment | 4 || end_markers_in_json | OFF |
| enforce_gtid_consistency | OFF || eq_range_index_dive_limit | 200 |
| error_count | 0 || event_scheduler | OFF |
| expire_logs_days | 0 || explicit_defaults_for_timestamp | OFF |
| external_user | || flush | OFF |
| flush_time | 0 || force_affinity | OFF |
| force_partial_repl_slave | OFF || force_ssl | OFF |
| force_ssl_ca | || force_ssl_capath | |
| force_ssl_cert | || force_ssl_cipher | |
| force_ssl_key | || foreign_key_checks | ON |
| fulltext_init_ratio | 0.5 || fulltext_max_batch_size | 64 |
| general_log | OFF || general_log_file | /var/lib/mysql/f1a7ad4d2b1c.log |
| group_concat_max_len | 1024 || group_replication_allow_local_id_assignment | OFF |
| group_replication_bootstrap_group | OFF || group_replication_clone_threshold | 8 |
| group_replication_communication_debug_options | || group_replication_communication_max_message_size | 1073741824 |
| group_replication_consistency | UNKNOWN || group_replication_enforce_update_everywhere_checks | OFF |
| group_replication_flover_on_data_loss | OFF || group_replication_flow_control_applier_threshold | 100 |
| group_replication_flow_control_certifier_threshold | 200 || group_replication_flow_control_hold_percent | 90 |
| group_replication_flow_control_max_commit_quota | 0 || group_replication_flow_control_member_quota_percent | 0 |
| group_replication_flow_control_min_commit_quota | 0 || group_replication_flow_control_min_certifier_quota | 0 |
| group_replication_flow_control_mode | QUOTA || group_replication_flow_control_period | 1s |
| group_replication_flow_control_release_percent | 50 || group_replication_force_members | |
| group_replication_group_name | || group_replication_group_seeds | |
| group_replication_gtid_assignment_block_size | 1000 || group_replication_ip_whitelist | |
| group_replication_local_address | || group_replication_member_expel_timeout | 0 |
| group_replication_member_weight | 50 || group_replication_poll_spin_loops | 0 |
| group_replication_recovery_complete_at | TRANSACTIONS || group_replication_recovery_get_public_key | OFF |
| group_replication_recovery_public_key_path | || group_replication_recovery_reconnect_interval | 60 |
| group_replication_recovery_retry_interval | 10 || group_replication_recovery_ssl_ca | |
| group_replication_recovery_ssl_capath | || group_replication_recovery_ssl_cert | |
| group_replication_recovery_ssl_cipher | || group_replication_recovery_ssl_crl | |
| group_replication_recovery_ssl_crlpath | || group_replication_recovery_ssl_key | |
| group_replication_recovery_ssl_verify_server_cert | OFF || group_replication_recovery_use_ssl | OFF |
| group_replication_recovery_zstd_compression_level | 3 || group_replication_single_primary_mode | OFF |
| group_replication_ssl_mode | REQUIRED || have_compress | YES |
| have_dynamic_loading | YES || have_geometry | YES |
| have_openssl | YES || have_profiling | YES |
| have_query_cache | YES || have_rtree_keys | YES |
| have_ssl | YES || have_statement_timeout | YES |
| have_symlink | DISABLED || histogram_generation_max_mem_size | 20000 |
| host_cache_size | 279 || hostname | f1a7ad4d2b1c |
| identity | 0 || ignore_builtin_innodb | OFF |
| ignore_db_dirs | || init_connect | |
| init_file | || init_slave | |
| innodb_adaptive_flushing | ON || innodb_adaptive_flushing_lwm | 10 |
| innodb_adaptive_hash_index | ON || innodb_adaptive_hash_index_parts | 8 |
| innodb_adaptive_max_sleep_delay | 150000 || innodb_autoextend_increment | 64 |
| innodb_autoinc_lock_mode | 1 || innodb_background_scrub_data_check_interval | 3600 |
| innodb_background_scrub_data_compressed | OFF || innodb_background_scrub_data_interval | 604800 |
| innodb_background_scrub_data_uncompressed | OFF || innodb_buf_dump_status_frequency | 0 |
| innodb_buf_dumped | 36186 || innodb_buf_load_status_frequency | 0 |
| innodb_buf_loaded | 313 || innodb_buf_pool_bytes_data | 8388608 |
| innodb_buf_pool_bytes_dirty | 0 || innodb_buf_pool_bytes_misc | 4325376 |
| innodb_buf_pool_bytes_total | 12713984 || innodb_buf_pool_dump_status | Dumping buffer pool(s) |
| innodb_buf_pool_load_abort | OFF || innodb_buf_pool_load_status | Loading buffer pool(s) |
| innodb_buf_pool_pages_data | 512 || innodb_buf_pool_pages_dirty | 0 |
| innodb_buf_pool_pages_flushed | 36180 || innodb_buf_pool_pages_free | 8187 |
| innodb_buf_pool_pages_misc | 317 || innodb_buf_pool_pages_total | 8704 |
| innodb_buf_pool_resize_incr_mem | 0 || innodb_buf_pool_resize_status | |
| innodb_buf_pool_resize_status_at_checkpoint | M || innodb_buf_pool_resize_status_interval | 60 |
| innodb_buf_pool_wt_free | 0 || innodb_buf_pool_write_requests | 115363 |
| innodb_buffer_pool_dump_pct | 25 || innodb_buffer_pool_dumped | 0 |
| innodb_buffer_pool_filename | ib_buffer_pool || innodb_buffer_pool_flush_pct | 75 |
| innodb_buffer_pool_instances | 1 || innodb_buffer_pool_load_pct | 0 |
| innodb_buffer_pool_loads | 1 || innodb_buffer_pool_max_size | 134217728 |
| innodb_buffer_pool_min_evict_rule | STRICT_LRU || innodb_buffer_pool_size | 8388608 |
| innodb_change_buffer_max_size | 25 || innodb_change_buffering | all |
| innodb_checkpoint_disabled | OFF || innodb_checkpoint_force_recovery | OFF |
| innodb_checkpoint_interval | 1440 || innodb_checkpoint_min_age | 300 |
| innodb_cleaner_lsn_age_factor | 32.0 || innodb_cleaner_max_lsn_age | 9223372036854775807 |
| innodb_cleaner_page_buffer_size | 32768 || innodb_cmp_per_index_enabled | OFF |
| innodb_commit_concurrency | 0 || innodb_compression_algorithm | lz4 |
| innodb_compression_default | OFF || innodb_compression_flure_threshold_pct | 5 |
| innodb_compression_level | 6 || innodb_compression_pad_pct_max | 50 |
| innodb_concurrency_tickets | 5000 || innodb_data_file_path | ibdata1:10M:autoextend |
| innodb_data_home_dir | || innodb_deadlock_detect | ON |
| innodb_dedicated_server | OFF || innodb_defragment | ON |
| innodb_defragment_fill_factor | 0.9 || innodb_defragment_fill_factor_n_recs | 20 |
| innodb_defragment_frequency | 40 || innodb_defragment_n_pages | 7 |
| innodb_defragment_stats_accuracy | 0 || innodb_disable_sort_file_cache | OFF |
| innodb_disallow_writes | OFF || innodb_doublewrite | ON |
| innodb_encrypt_log | OFF || innodb_encrypt_tables | OFF |
| innodb_encryption_rotation_iops | 100 || innodb_encryption_rotation_period | 1 |
| innodb_enhanced_alter | ON || innodb_err_file | |
| innodb_export_estimate | OFF || innodb_fast_shutdown | 1 |
| innodb_fatal_semaphore_wt_threshold | 600 || innodb_file_format | Barracuda |
| innodb_file_format_check | ON || innodb_file_format_max | Barracuda |
| innodb_file_per_table | ON || innodb_flush_log_at_timeout | 1 |
| innodb_flush_log_at_trx_commit | 1 || innodb_flush_method | O_DIRECT |
| innodb_flush_neighbors | 1 || innodb_flush_sync | ON |
| innodb_flushing_avg_loops | 30 || innodb_force_load_corrupted | OFF |
| innodb_force_recovery | 0 || innodb_fsp_max_file_size | 0 |
| innodb_ft_aux_table | || innodb_ft_cache_size | 80000000 |
| innodb_ft_enable_diag_print | OFF || innodb_ft_enable_stopword | ON |
| innodb_ft_max_token_size | 84 || innodb_ft_min_token_size | 3 |
| innodb_ft_num_word_optimize | 2000 || innodb_ft_result_cache_limit | 2000000000 |
| innodb_ft_server_stopword_table | || innodb_ft_sort_pll_degree | 2 |
| innodb_ft_total_cache_size | 640000000 || innodb_ft_user_stopword_table | |
| innodb_idle_flush_pct | 100 || innodb_immediate_scrub_data_uncompressed | OFF |
| innodb_instrument_semaphores | OFF || innodb_io_capacity | 200 |
| innodb_io_capacity_max | 2000 || innodb_kill_idle_transaction | 0 |
| innodb_large_prefix | ON || innodb_lock_schedule_algorithm | fcfs |
| innodb_lock_wt_timeout | 50 || innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_buffer_size | 8388608 || innodb_log_checksum_algorithm