Search code examples
mysqltypo3ssh-tunnel

TYPO3 and MySQL database on separate servers


Is it possible to run TYPO3 (6.0) and MySQL on separate servers with TYPO3 connecting to the database through a SSH tunnel?


Solution

  • This should be possible. However, it depends how your web hoster manages access from remote servers. For TYPO3 4.x, it's something like that in localconf.php:

    $typo_db_username = 'mysql_user';
    $typo_db_password = 'mysql_password';
    $typo_db_host = '127.0.0.1:12345';
    $typo_db = 'mysql_dbname';
    

    For TYPO3 > 6.x, it's in LocalConfiguration.php:

    return array(
      [...]
      'DB' => array(
      'database' => 'mysql_dbname',
      'host' => '127.0.0.1:12345',
      'password' => 'mysql_password',
      'username' => 'mysql_user',
      ),
      [...]
    );
    

    Where 12345 is the local port you used to set up the tunnel:

    ssh -L 12345:127.0.0.1:3306 ssh_user@remoteserver.com
    

    On most servers, you can use localhost instead of 127.0.0.1.
    IMHO, the security bottleneck is how the remote MySQL server handles incoming connections. I guess you can also set ths in via the install tool.

    EDIT: Changed the host according to hints from comments.