#!/bin/bash

if [ "$1" = '' ]; then
        echo "Please type in an username.";
        exit 2;
fi

if [ "$2" = '' ]; then
        echo "Please type in a password.";
        exit 2;
fi

mysql -e "USE mysql; UPDATE user SET password = null, Plugin = 'mysql_native_password', authentication_string = PASSWORD('$2') WHERE User = '$1';";

# mysql -e "ALTER USER $1 IDENTIFIED BY '$2';";

# ist nicht so toll, wenn man z.B. mehrere hosts hat:
# mysql -e "SET PASSWORD FOR '$1'@'localhost' = PASSWORD('$2')"
