Matomo processes huge amounts of data and then stores this data in the database. For improved performance, Matomo tries to import a lot of data in the database at once using a Mysql feature called “LOAD DATA INFILE”. You can check whether your server supports this performance improvement in the Administration > System Check menu. The system checks two commands: LOAD DATA INFILE and LOAD DATA LOCAL INFILE (which also works when the MySQL server is on a different server than your web server). It’s enough if either one of these work.

If you are not seeing a green tick under “Database abilities”, try the following troubleshooting steps:

  • Check the “mysqld” process can access the file created in the tmp/assets directory in the matomo-installation:
    • give the process mysqld executable-access (+x) to files in path/to/matomo/tmp/assets/* and all parent folders.
    • check that the request isn’t blocked by apparmor or any other security-software when accessing this folder. If you are using Ubuntu, you may have to disable apparmor which prevents mysql from accessing files in path/to/matomo/tmp/*
      Edit the file /etc/apparmor.d/usr.sbin.mysqld and add the following path in the file: /path/to/matomo/tmp/assets/* rw,
      Then restart apparmor with sudo /etc/init.d/apparmor restart
    • in your Mysql configuration (my.cnf) set the following options: [mysqld] local-infile and [mysql] local-infile
      Then restart Mysql.

If the LOAD DATA INFILE is still not working, try the following:

  • check in your config/config.ini.php that you do not have enable_load_data_infile=0. If you see this line in the file, delete it.
  • and/or if you are using PHP-Mysqli, you must enable the PHP setting mysqli.allow_local_infile = On. (For additional security, you may also set this PHP setting mysqli.local_infile_directory to /path/to/matomo/tmp/assets/)
  • and/or update to the latest PHP version, or use the mysqli client (there are some known bugs with older PDO clients for mysql)
  • and/or switch the client to adapter=MYSQLI in the config/config.ini.php
  • and/or disable in your php configuration php.ini the options open_basedir and safe_mode. Restart webserver.
  • on Ubuntu / Debian servers, you may try to uninstall php5-mysql package and install instead php5-mysqlnd: sudo apt-get install php5-mysqlnd
  • on some systems you may also need to set secure_file_priv="" under [mysqld]
  • You can change the permission for your Mysql user to allow the user to import the files: GRANT FILE on *.* to matomo@localhost. Note it is generally not recommended for security reasons, and LOAD DATA LOCAL INFILE should work without this additional GRANT FILE permission.

If you still cannot make LOAD DATA INFILE work, you can disable this feature completely. This is not recommended for medium to high traffic Matomo where this feature should be enabled. To disable LOAD DATA INFILE add to your config.ini.php file under [General] section: enable_load_data_infile=0

Previous FAQ: How do I specify to use Mysql on a custom port or to connect Mysql over a socket?