1
This commit is contained in:
commit
e509155207
2
README.md
Normal file
2
README.md
Normal file
@ -0,0 +1,2 @@
|
||||
* <https://tableplus.com/blog/2018/10/how-to-create-a-superuser-in-mysql.html>
|
||||
|
27
mysql-create-superuser.sh
Executable file
27
mysql-create-superuser.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PWGEN=`which pwgen`
|
||||
if [ -z "${PWGEN}" ];
|
||||
then
|
||||
echo "Could not finf \"pwgen\" binary"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
AUTOGEN_PASSWORD=`pwgen -n1 -v 40`
|
||||
USERNAME="$1"
|
||||
|
||||
if [ -z "${USERNAME}" ];
|
||||
then
|
||||
echo "Missing username"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
CREATE USER '${USERNAME}'@'localhost' IDENTIFIED BY '${AUTOGEN_PASSWORD}';
|
||||
GRANT ALL PRIVILEGES ON *.* TO '${USERNAME}'@'localhost' WITH GRANT OPTION;
|
||||
CREATE USER '${USERNAME}'@'%' IDENTIFIED BY '${AUTOGEN_PASSWORD}';
|
||||
GRANT ALL PRIVILEGES ON *.* TO '${USERNAME}'@'%' WITH GRANT OPTION;
|
||||
SHOW GRANTS FOR ${USERNAME};
|
||||
FLUSH PRIVILEGES;
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user