Home / code / Bash script to create linux and mysql user

Bash script to create linux and mysql user

#!/bin/bash
MKP=/usr/bin/mkpasswd
echo "Creating user: $1"
PASSWD=`$MKP`
echo "Password: $PASSWD"
ENPASSWD="$MKP $PASSWD"
useradd $1 -p "$ENPASSWD"
echo "Creating mysql user & database for $1"
mysql -u root --password=your_mysql_password -e "CREATE DATABASE $1; CREATE USER $1 IDENTIFIED BY '$PASSWD'; GRANT ALL ON $1.* TO '$1'"
chmod +x lmuser.sh
./lmuser.sh users

About panev

Check Also

KVM виртуализация старт на virt-manager грешка

KVM виртуализация старт на virt-manager грешка Днес се наложи да инсталирам на CentOS 6.8 KVM …