问题描述
今天我注意到突然在我的数据库中创建了许多视图,其中大部分视图与系统性能有关。我很确定我没有创建这些视图,因为所有的 DEFINER 都是
DEFINER=MysqL.sys
@localhost
我是否曾成为任何 sql 注入的受害者,是否有人对我的数据库进行了调教,或者是否有人错误地更改了创建这些视图的任何配置?
如果这是配置更改,我该如何撤消配置更改,如果还有其他问题,可能的解决方案是什么?
以下是创建的视图。
host_summary
host_summary_by_file_io
host_summary_by_file_io_type
host_summary_by_stages
host_summary_by_statement_latency
host_summary_by_statement_type
innodb_buffer_stats_by_schema
innodb_buffer_stats_by_table
innodb_lock_waits
io_by_thread_by_latency
io_global_by_file_by_bytes
io_global_by_file_by_latency
io_global_by_wait_by_bytes
io_global_by_wait_by_latency
latest_file_io
memory_by_host_by_current_bytes
memory_by_thread_by_current_bytes
memory_by_user_by_current_bytes
memory_global_by_current_bytes
memory_global_total
metrics
processlist
ps_check_lost_instrumentation
schema_auto_increment_columns
schema_index_statistics
schema_object_overview
schema_redundant_indexes
schema_table_lock_waits
schema_table_statistics
schema_table_statistics_with_buffer
schema_tables_with_full_table_scans
schema_unused_indexes
session
session_ssl_status
statement_analysis
statements_with_errors_or_warnings
statements_with_full_table_scans
statements_with_runtimes_in_95th_percentile
statements_with_sorting
statements_with_temp_tables
user_summary
user_summary_by_file_io
user_summary_by_file_io_type
user_summary_by_stages
user_summary_by_statement_latency
user_summary_by_statement_type
version
wait_classes_global_by_avg_latency
wait_classes_global_by_latency
waits_by_host_by_latency
waits_by_user_by_latency
waits_global_by_latency
x$host_summary
x$host_summary_by_file_io
x$host_summary_by_file_io_type
x$host_summary_by_stages
x$host_summary_by_statement_latency
x$host_summary_by_statement_type
x$innodb_buffer_stats_by_schema
x$innodb_buffer_stats_by_table
x$innodb_lock_waits
x$io_by_thread_by_latency
x$io_global_by_file_by_bytes
x$io_global_by_file_by_latency
x$io_global_by_wait_by_bytes
x$io_global_by_wait_by_latency
x$latest_file_io
x$memory_by_host_by_current_bytes
x$memory_by_thread_by_current_bytes
x$memory_by_user_by_current_bytes
x$memory_global_by_current_bytes
x$memory_global_total
x$processlist
x$ps_digest_95th_percentile_by_avg_us
x$ps_digest_avg_latency_distribution
x$ps_schema_table_statistics_io
x$schema_flattened_keys
x$schema_index_statistics
x$schema_table_lock_waits
x$schema_table_statistics
x$schema_table_statistics_with_buffer
x$schema_tables_with_full_table_scans
x$session
x$statement_analysis
x$statements_with_errors_or_warnings
x$statements_with_full_table_scans
x$statements_with_runtimes_in_95th_percentile
x$statements_with_sorting
x$statements_with_temp_tables
x$user_summary
x$user_summary_by_file_io
x$user_summary_by_file_io_type
x$user_summary_by_stages
x$user_summary_by_statement_latency
x$user_summary_by_statement_type
x$wait_classes_global_by_avg_latency
x$wait_classes_global_by_latency
x$waits_by_host_by_latency
x$waits_by_user_by_latency
x$waits_global_by_latency
解决方法
没问题。注意这些视图在哪些数据库中。它们在系统数据库中(可能是 sys、information_schema、performance_schema 和 MySQL),而不是你的。而且,是的,那些是故意的观点。
“突然”——您最近是否升级到新版本的 MySQL?过去没有任何系统生成的视图。
,sys
架构中存在视图并不能证明您是 SQL 注入或篡改的受害者。
这些观点是官方的并记录在案:https://dev.mysql.com/doc/refman/8.0/en/sys-schema.html
sys
架构在 MySQL 5.6 中是可选的。这些视图是由 MySQL 的一名工程经理开发的。但在 5.6 中,您必须通过运行从 github 下载的 SQL 脚本手动安装它们(请参阅 https://github.com/mysql/mysql-sys)。
在 MySQL 5.7 中,sys
架构成为默认安装的一部分。如果您从 MySQL 5.6 升级到 5.7,将安装 sys
架构,以及对系统架构(如 mysql
、information_schema
和 {{1})中的一些其他表和视图的更改}}。
我们的一位开发人员启用了性能监控,因此创建了这些视图。