6 Star 4 Fork 1

sunny/dzzwithdocker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
create_mysql_admin_user.sh 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
sunny 提交于 2014-05-23 08:21 . build new
#!/bin/bash
if [ -f /.mysql_admin_created ]; then
echo "MySQL 'admin' user already created!"
exit 0
fi
/usr/bin/mysqld_safe > /dev/null 2>&1 &
PASS=admin
_word=$PASS
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
echo "=> Creating MySQL admin user with ${_word} password"
mysql -uroot -e "CREATE USER 'admin'@'%' IDENTIFIED BY '$PASS'"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION"
mysqladmin -uroot shutdown
echo "=> Done!"
touch /.mysql_admin_created
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 "========================================================================"
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/tufeiping/dzzwithdocker.git
git@gitee.com:tufeiping/dzzwithdocker.git
tufeiping
dzzwithdocker
dzzwithdocker
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385