一. 查看操作系统信息
[root@localhost ~]# cat /etc/.kyinfo
[dist]
name=Kylin
milestone=Server-V10-GFB-Release-ZF9_01-2204-Build03
arch=arm64
beta=False
time=2023-01-09 11:04:36
dist_id=Kylin-Server-V10-GFB-Release-ZF9_01-2204-Build03-arm64-2023-01-09 11:04:36
[servicekey]
key=0080176
[os]
to=
term=2024-05-16
二、查看数据库信息
1 .查看数据库版本
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.3.0 |
+-----------+
1 row in set (0.00 sec)
2. 查看日志文件是否开启
mysql> show variables like 'general_log';
+--------------------+----------+
| Variable_name | Value |
+--------------------+---------+
| general_log | ON |
+--------------------+---------+
1 row in set (0.02 sec)
3. 查看日志文件位置
mysql> show variables like 'general_log_file';
+----------------------+----------------------------------------------+
| Variable_name | Value |
+-----------------------+---------------------------------------------+
| general_log_file | /usr/local/mysql/logs/general_log |
+-----------------------+--------------------------------------------+
1 row in set (0.01 sec)
4. 查看日志文件保存的类型
mysql> show variables like 'log_output';
+---------------+--------------+
| Variable_name | Value |
+---------------+-------------+
| log_output | FILE |
+---------------+-------------+
1 row in set (0.01 sec)
三、操作 general 日志
1. 删除general日志
(1)关闭 general 日志功能
mysql> SET GLOBAL general_log='OFF';
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'general_log';
+--------------------+------------+
| Variable_name | Value |
+--------------------+------------+
| general_log | OFF |
+--------------------+------------+
1 row in set (0.01 sec)
(2)查看当前的 general 日志
[root@localhost logs]# ls
general_log mysql_error.log
(3)重命名 general 日志表名称
mysql> use mysql;
Database changed
查看表
mysql> show tables;
+------------------------------------------------------+
| Tables_in_mysql |
+------------------------------------------------------+
| columns_priv |
| component |
| db |
| default_roles |
| engine_cost |
| func |
| general_log |
| global_grants |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| password_history |
| plugin |
| procs_priv |
| proxies_priv |
| replication_asynchronous_connection_failover |
| replication_asynchronous_connection_failover_managed |
| replication_group_configuration_version |
| replication_group_member_actions |
| role_edges |
| server_cost |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+------------------------------------------------------+
38 rows in set (0.01 sec)
审计表重命名
mysql> RENAME TABLE general_log TO general_log_0;
Query OK, 0 rows affected (0.15 sec)
删除 general 表
mysql> DELETE FROM general_log_0;
Query OK, 0 rows affected (0.04 sec)
删除 general_log文件
[root@localhost logs]# rm -rf general_log
四. 临时开启 general 日志
1. 重新开启 general 日志
(1)将原来的表名更改回来
mysql> RENAME TABLE general_log_0 TO general_log;
Query OK, 0 rows affected (0.11 sec)
(2)重新开启 general 日志功能
mysql> SET GLOBAL general_log = 'ON';
Query OK, 0 rows affected (0.03 sec)
(3)查看新生成的 general 日志
[root@localhost logs]# ls
general_log
五、永久设置 general 日志
1. 开启 general 日志
[root@localhost conf]# vi
general_log = ON
general_log_file = /usr/local/mysql/logs/general_log
log_output = FILE
2. 关闭 general 日志
[root@localhost conf]# vi
general_log = OFF
general_log_file = /usr/local/mysql/logs/general_log
log_output = FILE