Skip to main content
Simplify title, add tag
Link

MySQL CLI: Create an authenticated, all privilegeda MySQL user + a& DB with the same name

edited body
Source Link

Please review my Bash code to create an authenticated, all privileged MySQL user plus a DB with the same name, through the MySQL CLI:

read -sp "DB user password:" dbrootp_1       && echo
read -sp "DB user password again:" dbuserp_2dbrootp_2 && echo
read -sp "DB user password:" dbrootp_1dbuserp_1       && echo
read -sp "DB user password again:" dbuserp_2 && echo

if [ "$dbrootp_1" != "$dbrootp_2" ]; then echo "Values unmatched" && exit 1 fi
if [ "$dbuserp_1" != "$dbuserp_2" ]; then echo "Values unmatched" && exit 1 fi

cat <<-DBSTACK | mysql -u root -p"$dbrootp"
    CREATE USER "$domain"@"localhost" IDENTIFIED BY "$dbuserp";
    CREATE DATABASE "$domain";
    GRANT ALL PRIVILEGES ON "$domain".* TO "$domain"@"localhost";
DBSTACK

Please review my Bash code to create an authenticated, all privileged MySQL user plus a DB with the same name, through the MySQL CLI:

read -sp "DB user password:" dbrootp_1       && echo
read -sp "DB user password again:" dbuserp_2 && echo
read -sp "DB user password:" dbrootp_1       && echo
read -sp "DB user password again:" dbuserp_2 && echo

if [ "$dbrootp_1" != "$dbrootp_2" ]; then echo "Values unmatched" && exit 1 fi
if [ "$dbuserp_1" != "$dbuserp_2" ]; then echo "Values unmatched" && exit 1 fi

cat <<-DBSTACK | mysql -u root -p"$dbrootp"
    CREATE USER "$domain"@"localhost" IDENTIFIED BY "$dbuserp";
    CREATE DATABASE "$domain";
    GRANT ALL PRIVILEGES ON "$domain".* TO "$domain"@"localhost";
DBSTACK

Please review my Bash code to create an authenticated, all privileged MySQL user plus a DB with the same name, through the MySQL CLI:

read -sp "DB user password:" dbrootp_1       && echo
read -sp "DB user password again:" dbrootp_2 && echo
read -sp "DB user password:" dbuserp_1       && echo
read -sp "DB user password again:" dbuserp_2 && echo

if [ "$dbrootp_1" != "$dbrootp_2" ]; then echo "Values unmatched" && exit 1 fi
if [ "$dbuserp_1" != "$dbuserp_2" ]; then echo "Values unmatched" && exit 1 fi

cat <<-DBSTACK | mysql -u root -p"$dbrootp"
    CREATE USER "$domain"@"localhost" IDENTIFIED BY "$dbuserp";
    CREATE DATABASE "$domain";
    GRANT ALL PRIVILEGES ON "$domain".* TO "$domain"@"localhost";
DBSTACK
deleted 71 characters in body
Source Link

Please review my Bash code to create an authenticated, all privileged MySQL user plus a DB with the same name, through the MySQL CLI:

read -sp "DB user password:" dbrootp_1       && echo
read -sp "DB user password again:" dbuserp_2
  && echo
read -sp "DB user password:" dbrootp_1       && echo
read -sp "DB user password again:" dbuserp_2 && echo

if [ "$dbrootp_1" != "$dbrootp_2" ]; then
    echo >&2 "foos did not match"
 "Values unmatched" && exit 1
  fi
 
if [ "$dbuserp_1" != "$dbuserp_2" ]; then
    echo >&2 "foos did not match"
 "Values unmatched" && exit 1
fi

# --------------------------------------------------------------- #fi

cat <<-DBSTACK | mysql -u root -p"$dbrootp"
    CREATE USER "$domain"@"localhost" IDENTIFIED BY "$dbuserp";
    CREATE DATABASE "$domain";
    GRANT ALL PRIVILEGES ON "$domain".* TO "$domain"@"localhost";
DBSTACK

Please review my Bash code to create an authenticated, all privileged MySQL user plus a DB with the same name, through the MySQL CLI:

read -sp "DB user password:" dbrootp_1
read -sp "DB user password:" dbuserp_2
 
read -sp "DB user password:" dbrootp_1
read -sp "DB user password:" dbuserp_2

if [ "$dbrootp_1" != "$dbrootp_2" ]; then
    echo >&2 "foos did not match"
    exit 1
 fi
 
if [ "$dbuserp_1" != "$dbuserp_2" ]; then
    echo >&2 "foos did not match"
    exit 1
fi

# --------------------------------------------------------------- #

cat <<-DBSTACK | mysql -u root -p"$dbrootp"
    CREATE USER "$domain"@"localhost" IDENTIFIED BY "$dbuserp";
    CREATE DATABASE "$domain";
    GRANT ALL PRIVILEGES ON "$domain".* TO "$domain"@"localhost";
DBSTACK

Please review my Bash code to create an authenticated, all privileged MySQL user plus a DB with the same name, through the MySQL CLI:

read -sp "DB user password:" dbrootp_1       && echo
read -sp "DB user password again:" dbuserp_2 && echo
read -sp "DB user password:" dbrootp_1       && echo
read -sp "DB user password again:" dbuserp_2 && echo

if [ "$dbrootp_1" != "$dbrootp_2" ]; then echo "Values unmatched" && exit 1 fi
if [ "$dbuserp_1" != "$dbuserp_2" ]; then echo "Values unmatched" && exit 1 fi

cat <<-DBSTACK | mysql -u root -p"$dbrootp"
    CREATE USER "$domain"@"localhost" IDENTIFIED BY "$dbuserp";
    CREATE DATABASE "$domain";
    GRANT ALL PRIVILEGES ON "$domain".* TO "$domain"@"localhost";
DBSTACK
added 60 characters in body
Source Link
Loading
Source Link
Loading