Skip to content

Instantly share code, notes, and snippets.

@KarelWintersky
Forked from valerio-bozzolan/mysql.sh
Created September 6, 2016 16:13
Show Gist options
  • Save KarelWintersky/b80f4d44cee2f223cde01239dbcddaa2 to your computer and use it in GitHub Desktop.
Save KarelWintersky/b80f4d44cee2f223cde01239dbcddaa2 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