-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_mysql_admin_user.sh
38 lines (32 loc) · 1.15 KB
/
create_mysql_admin_user.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
mysql_install_db
/usr/bin/mysqld_safe > /dev/null 2>&1 &
RET=1
while [[ RET -ne 0 ]]; do
echo "=> Waiting for confirmation of MySQL service startup"
sleep 5
mysql -uroot -e "status" > /dev/null 2>&1
RET=$?
done
PASS="godsadasodakso#!@ds"
mysql_install_db
mysql -uroot -e "CREATE database ctf"
mysql -uroot -e "GRANT ALL ON ctf.* TO 'admin'@'localhost' IDENTIFIED BY '$PASS'"
# mysql -uroot -e "GRANT FILE ON *.* TO 'admin'@'localhost'"
mysql -uroot -e "flush privileges"
mysql -uroot ctf < /var/www/html/web2/database.sql
rm /var/www/html/web2/database.sql
# You can create a /mysql-setup.sh file to intialized the DB
if [ -f /mysql-setup.sh ] ; then
. /mysql-setup.sh
fi
echo "=> Done!"
echo "========================================================================"
echo "You can now connect to this MySQL Server using:"
echo ""
echo " mysql -uadmin -p$PASS -h<host> -P<port>"
echo ""
echo "Please remember to change the above password as soon as possible!"
echo "MySQL user 'root' has no password but only allows local connections"
echo "========================================================================"
mysqladmin -uroot shutdown