[KB8595] Install MySQL 5 for ESET Inspect server on Linux

Issue

Solution

Install MySQL 5

Supported Linux versions for MySQL 5

MySQL 5 can only be installed on Linux distributions that still provide MySQL 5.7 in their default repositories (for example, Ubuntu 16.04 LTS or 18.04 LTS). Later Linux versions no longer include MySQL 5.7 by default and require manual setup using the official MySQL APT repository.

If you are using a later Linux version, install MySQL 8.

  1. In the terminal, run the following commands:

    sudo apt-get update
    
    sudo apt-get upgrade
    
    sudo apt-get install mysql-server-5.7
  2. Install MySQL Workbench, which is the database GUI (Graphical User Interface). In the terminal, run:

    sudo apt install mysql-workbench

Set up the MySQL database

  1. In the terminal, run the following command to open the MySQL command line client:

    sudo mysql -u root -p

    If prompted, type your MySQL root password. You should now see mysql> within the terminal, indicating that you are inside the MySQL command line client. Everything you type now is an SQL command, not a regular terminal command.

  2. Set up the database user account for localhost and external connections. Run the following SQL commands in the MySQL command line client:

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin';
    
    CREATE USER 'root'@'%' IDENTIFIED BY 'admin';
    
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
    
    FLUSH PRIVILEGES;

    The commands update the password for the local root user account (root'@'localhost, created by default during MySQL installation) to admin, and create a remote-accessible root user account (root'@'%) with the same password (admin) and full privileges. You can replace the placeholder password admin in the commands with a secure password of your choice.

    Remote-accessible database user account password

    The password of the remote-accessible user account (root'@'%) will be required during the ESET Inspect Server installation.

    You can change the password for the remote-accessible user account (root'@'%) as follows:

    • From the MySQL command line client with: ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'new_password'; 
    • From the terminal with: sudo mysql -e "ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'new_password';
    • From MySQL Workbench:

      1. In the terminal, run mysql-workbench to open MySQL Workbench.

      2. In MySQL Workbench, click DatabaseConnect to Database. Select the database connection and click OK. Type the user password and click OK.

      3. Click ServerUsers and Privileges. Select the root user entry where the host is %, set and confirm the password and click Apply.

  3. Verify that both the local and remote root user accounts are configured. Run:

    SELECT Host, User FROM mysql.user WHERE User='root';

    You should see entries for 'root'@'%' and 'root'@'localhost', confirming that the user accounts are correctly configured.

    You can exit the MySQL command line client by running:

    exit;

    After exiting, you should no longer see mysql> in the terminal.

  4. After the user accounts are configured, set up the MySQL database. In the terminal, run:

    mysql_secure_installation

    When prompted, answer the questions as follows:

    VALIDATE PASSWORD PLUGIN [Y/n] n
    
    Change the password for root? [Y/n] n
    
    Remove anonymous users? [Y/n] y
    
    Disallow root login remotely? [Y/n] n
    
    Remove test database and access to it? [Y/n] y
    
    Reload privilege tables now? [Y/n] y
  5. Copy the mysql.service file. In the terminal, run:

    sudo cp /lib/systemd/system/mysql.service /etc/systemd/system/
  6. Open the /etc/systemd/system/mysql.service file in a text editor and add the following lines:

    LimitNOFILE=30000
    
    LimitMEMLOCK=30000

    To open the file from the terminal, run:

    sudo nano /etc/systemd/system/mysql.service
  7. Save the file and reload the system configuration. In the terminal, run:

    sudo systemctl daemon-reload
  8. Open the /etc/mysql/mysql.conf.d/mysqld.cnf file in a text editor and update it as specified below.

    To open the file from the terminal, run:

    sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
    • Under the [mysqld] section, update the following parameters:

      bind-address = {IP_OF_THIS_MACHINE}
      
      thread_stack = 256K

      Replace {IP_OF_THIS_MACHINE} in bind-address with the IP address of the machine where the MySQL database is running. Do not use the default value 127.0.0.1. (localhost), as this allows only local connections. ESET Inspect On-Prem will not be able to connect to the MySQL database if the IP address is incorrect.

    • Under the [mysqld] section, add the following parameters:

      innodb_buffer_pool_size=4G
      
      innodb_flush_log_at_trx_commit=0
      
      innodb_log_file_size=2G

      The values for innodb_buffer_pool_size and innodb_log_file_size are examples. Set innodb_buffer_pool_size to 80% of the MySQL server machine's available RAM. Set innodb_log_file_size to 40-60% of the innodb_buffer_pool_size value.

    • At the end of the file, add the following lines:

      event_scheduler = ON
      
      wait_timeout=900
      
      max_connections=300
  9. Restart MySQL to load the new parameters. In the terminal, run:

    sudo service mysql restart

Verify the MySQL service status

In the terminal, run:

systemctl status mysql.service

The MySQL service is running when Active: active (running) is indicated.


Sources