Skip to content

Instantly share code, notes, and snippets.

@irusri
Forked from valerio-bozzolan/mysql.sh
Created March 21, 2016 21:48
Show Gist options
  • Select an option

  • Save irusri/1ee2d6380474569aa9c1 to your computer and use it in GitHub Desktop.

Select an option

Save irusri/1ee2d6380474569aa9c1 to your computer and use it in GitHub Desktop.
Debian GNU/Linux MySQL-MariaDB autologin
#!/bin/bash
########################################
# MySQL | MariaDB autologin
# License: GNU GPL v3+
# Author: Valerio Bozzolan
########################################
file=/etc/mysql/debian.cnf
while [ -z "$user" ] && read ln; do
[[ "$ln" =~ user\ *=\ (.*)$ ]]
user="${BASH_REMATCH[1]}"
done < $file
while [ -z "$pass" ] && read ln; do
[[ "$ln" =~ password\ *=\ (.*)$ ]]
pass="${BASH_REMATCH[1]}"
done < $file
mysql --user="$user" --password="$pass" $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment