Login Putty and Mysql in one click

5,943

Solution 1

The problem got solved (on Windows).

  1. Install MTPuTTY. Browse to your Putty location.

  2. Setup a session: host, username, password. This step enables automatically login to Putty.

  3. Choose Script tab. Enter the scripts you want to run after login to Putty. Set delay time ~2000 milliseconds.

DONE!

Solution 2

PuTTY has a configuration option to run a specific shell command after connecting to the SSH server. You can set this as part of a saved configuration, i.e. Skynet - start MySQL.

enter image description here

As Ben Orchard notes, you will still want to enter your SQL password manually, as opposed to storing it as part of a configuration file.

Solution 3

You could place a few lines in your shell profile on the machine you are connecting to to automatically login to MySQL if you it detects you are using SSH. See here:

if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
    mysql -u a_user -p
fi

Put those lines at the end of your shell profile (e.g. ~/.bash_profile). When you login via SSH, your shell should prompt you for your MySQL password immediately when you connect via SSH.

I'm not certain if you can pass your MySQL password as an argument, if you that's what you wanted - and I suggest against it, because it would not be very secure at all.

Share:
5,943

Related videos on Youtube

brittd
Author by

brittd

Updated on September 18, 2022

Comments

  • brittd
    brittd over 1 year

    I'd like to login Putty and MySQL in one step. How to do it?

    I tried this way but it only logins Putty.

    I'm using Windows. If possible please show more a Linux version.