Lanyiyun: Tutorial on installing the mysql plug-in server_audit.so in centos7 system

To install the MySQL plug-in server_audit.so in CentOS 7 system, you can follow the following steps:

  1. Download the server_audit.so plug-in file:
    Visit the official MySQL website or a third-party trusted source and download the server_audit.so plug-in file for your MySQL version. Make sure to select the file that matches your MySQL version and architecture (32-bit or 64-bit).
  2. Copy the plug-in file to the MySQL plug-in directory:
    Copy the downloaded server_audit.so plug-in file to the MySQL plug-in directory. By default, the MySQL plugin directory is located  /usr/lib64/mysql/plugin/.

    sudo cp /path/to/server_audit.so /usr/lib64/mysql/plugin/
  3. Modify the MySQL configuration file:
    Edit the MySQL configuration file  my.cnfor  my.iniadd the server_audit plug-in configuration.

    sudo vi /etc/my.cnf

    Add the following at the end of the file:

    # 配置server_audit插件
    server_audit_logging=ON
    server_audit_events=CONNECT,QUERY
    server_audit_file_path=/var/log/mysql/audit.log

    server_audit_logging=ONIt means turning on the server_audit plug-in and server_audit_eventsspecifying the event type to be recorded. The above configuration means recording user connection events and SQL query events. server_audit_file_pathSpecify the storage path of the log file and ensure that the path is writable by the MySQL process.

  4. Create the log file directory and set permissions:
    Create the specified log file directory and set the correct permissions for the MySQL process.

    sudo mkdir /var/log/mysql
    sudo chown mysql:mysql /var/log/mysql
  5. Restart the MySQL service:
    After completing the above steps, restart the MySQL service to make the configuration take effect.

    sudo systemctl restart mysqld

Now, the MySQL plugin server_audit.so has been successfully installed and configured to log user connection and SQL query events. You can  /var/log/mysql/audit.logview and analyze these events in . Please note, make sure you obtain the server_audit.so plugin file from a trustworthy source and make appropriate configuration and permission settings to ensure system security and stability.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/133419566