Access Your MySQL Server Remotely Over SSH

So you’ve got MySQL on your web server, but it’s only opened to local ports by default for security reasons. If you want to access your database from a client tool like the MySQL Query Browser, normally you’d have to open up access from your local IP address… but that’s not nearly as secure.

So instead, we’ll just use port-forwarding through an SSH tunnel, so your MySQL client thinks it’s connecting to your localhost machine, but it’s really connecting to the other server through the tunnel.

If you are using the command line ssh, the command would look like this. (You can do the same thing graphically in Putty or SecureCRT options if you need to)

ssh -L 3306:localhost:3306

The syntax is ssh -L <localport>hostname<remoteport> <username>@<servername>. We’re using localhost as the hostname because we are directly accessing the remote mysql server through ssh. You could also use this technique to port-forward through one ssh server to another server.

If you already have mysql running on your local machine then you can use a different local port for the port-forwarding, and just set your client tools to access MySQL on a different port.

Once you’ve got the ssh tunnel going, you can open up MySQL Query Browser and enter in the details for your remote server, using localhost as the server host, and adjust the port to whatever you used.

How to setup DELL DRAC card for ssh

This setup shows using DHCP for the DRAC ip address, but it can be hard set as well.

    * Enter setup F2
         1. Cursor down to Serial Communications.
         2. Set the other fields to the following.
                o Serial Communication : On with console Redirection via COM2
                o External Serial Connector : Remote Access Device
                o Failsafe Baud Rate : 57600
                o Remote Terminal Type : VT100/VT200
                o Redirection After Boot: Enabled 

         3. Save and exit. 

    * Enter the RAC configuration when prompted CTRL-E

          o Set the ip address to DHCP
          o Set the LAN User password to the current console password.
          o Write down the DRAC MAC address.

          o Save and Exit

Enter the MAC address in dhcp on your dhcp server dhcpd.conf in the appropriate section.
Restart DHCPNow we should be able to ssh to the console.

 ssh vt-11-c -l root

 root@vt-11-c's password:
 Warning: No xauth data; using fake authentication data for X11 forwarding.

 Dell Remote Access Controller 5 (DRAC 5)
 Firmware Version 1.20 (Build 07.03.02)


To get to the console type:

 connect com2

This message flashes…

 Connected to com2. To end type: '^'

Then you should have the console login.

 Red Hat Enterprise Linux WS release 4 (Nahant Update 5)
 Kernel 2.6.9-55.ELsmp on an x86_64

 vt-11 login:

To escape type ‘CTRL’ + »


To change root password on a DRAC from ssh shell

 $ racadm config -g cfgUserAdmin -o cfgUserAdminPassword -i 2 NewPasswordHere

Now to do power tasks on the dell type smclp.

 $ smclp
 DRAC5 SM-CLP System Management Shell, version 1.0
 Copyright (c) 2004-2007 Dell, Inc.
 All Rights Reserved

cd system1





    CreationClassName       = CIM_ComputerSystem
    Name                    = 7B0CZC1
    NameFormat              = other
    Dedicated               = 0
    ResetCapability         = 4
    EnabledState            = 2
    RequestedState          = 12
    EnabledDefault          = 2
    HealthState             = 5
    OperationalStatus       = 2
    Description             = PowerEdge 2970


    * To reboot the system type "reset"
    * To power off "stop"
    * To power on "start"