<commit_before>#!/bin/bash
# 用于重置MySQL密码
# 注意不可用于生产环境，具有潜在危险。
if [ "$(id -u)" != "0" ]; then
	echo "This script must be run as root!" 1>&2
	exit 1
fi
read -p "Please input username:" name
read -s -p "Please input new password:" pass
tmp_file=`mktemp`.sql
echo "UPDATE mysql.user SET Password=PASSWORD('$<PASSWORD>') WHERE User='$name';
FLUSH PRIVILEGES;" > $tmp_file
cat $tmp_file
echo 
kill -15 `pgrep mysqld`
mysqld_safe --init-file=$tmp_file &
ping -c 10 127.0.0.1 > /dev/null
kill -15 `pgrep mysqld`
rm $tmp_file
<commit_msg>完善MySQL密码重置脚本<commit_after>#!/bin/bash
# 用于重置MySQL密码
# 注意不可用于生产环境，具有潜在危险。
if [ "$(id -u)" != "0" ]; then
	echo "This script must be run as root!" 1>&2
	exit 1
fi
if [[ `pgrep mysqld` != "" ]]; then
	echo "Mysqld is running, please turn it off." 1>&2
	exit 1
fi
name=
pass=
while [[ "$name" == "" ]]; do
	read -p "Please input username: " name
done
while [[ "$pass" == "" ]]; do
	read -s -p "Please input new password: " first_pass
	echo
	read -s -p "Please input your new password again: " second_pass
	echo 
	if [[ "$first_pass" == "$second_pass" ]]; then
		pass="$first_pass"
	else
		echo "Two passwords do not match each other!" 1>&2
	fi
done
tmp_file=/tmp/.please_delete_me.sql
echo "UPDATE mysql.user SET Password=PASSWORD('$<PASSWORD>') WHERE User='$name';
FLUSH PRIVILEGES;" > $tmp_file
echo 
ping -c 2 127.0.0.1 > /dev/null
mysqld_safe --init-file=$tmp_file & > /dev/null
ping -c 10 127.0.0.1 > /dev/null
kill -10 `pgrep mysqld` 2> /dev/null
rm $tmp_file
{'fraction_non_alphanumeric': 0.1636485580147552, 'fraction_numerical': 0.028839704896042925, 'mean_word_length': 4.04054054054054, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5184786', 'n_tokens_mistral': 666, 'n_tokens_neox': 633, 'n_words': 186}