Access a mysql db via ssh port forwarding with rekall


Symptom

The database front-end for KDE rekall does not connect to a port forwarded connection to a mysql server.

When you try to connect through a ssh forwarded port by setting up a connection with rekall's "Database Connection Wizard", you get:

Unable to connect to MYSQL server

In the "Details" it shows:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

It seems that when you specify "localhost" as mysql server host, rekall tries to connect via unix sockets and not via tcp.
Give the localhost address as IP number "127.0.0.1" to get a working connection!

A typical configuration file example.rkl for rekall after being created by the "Database Connection Wizard" may look like this:

<?xml version="1.0" encoding="UTF=8"?>
<!DOCTYPE rekallDB>
<servers version="131072">
  <serverinfo
    DBType="mysql"
    SocketName=""
    HostName="127.0.0.1"
    PortNumber="3306"
    DBName="mysql"
    UserName="root"
    Password=""
    DataEncoding=""
    AutoStart="No"
    PKReadOnly="0"
    Flags=""
    NoRekallTables="0"
    InitSQL=""
    PrintQueries="0"
    CacheTables="0"
    AutoForm=""
    ObjEncoding=""
    ReadOnly="0"
    ShowAllTables="0"
    IsDisabled="No"
    NullUserPwd="0"
    SSHTarget=""
    ServerName="!Files"
    FakeKeys="0"
  />
</servers>

After having configured rekall that way and after having built up the ssh tunnel as in the example below, it should be possible to connect with rekall to the remote mysql server.

ssh port forwarding Example:

ssh -N -f -L localhost:3306:localhost:3306 <remote host with mysqld>

This builds the tunnel to the remote mysql server port (3306) via the local interface of <remote host with mysqld> and makes the mysql server port on the local machine available for a locally running mysql client.

The -N option inhibits the execution of a remote command which by default would be a shell.
The -f option brings the ssh program into background.

Forward a second mysql server to a different port on the local machine:

ssh -N -f -L localhost:13306:localhost:3306 <different remote host with mysqld>

short article on ssh port forwarding

line
linux logo Powered by Apache
line
This site maintained by:
lukas.zimmermann@unibas.ch
My public PGP key
last updated: 2009-09-18 Valid CSS! Valid XHTML 1.0 Strict