During the Matomo (Piwik) installation at the Database setup step, the host can be specified as:

  • hostname
  • IP address

You can specify a custom port number to connect Mysql (instead of default port 3306):

  • hostname:port
  • ipaddress:port

You can also specify to connect through a socket:

  • /sock/path – anything before the slash is ignored
  • localhost – localhost has a special meaning in php 5.3+; with mysqlnd, it means use the default sock path

If you have already installed Matomo you can configure the port or socket in the config.ini.php file below your [database] section:

 port = 3500
 unix_socket = /path/to/sock # if specified, it will override any specified hostname and/or port
Previous FAQ: How do I setup Matomo to securely connect to the database using MySQL SSL?