30 lines
734 B
Bash
Executable File
30 lines
734 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Define database connection variables
|
|
db_host="192.168.0.114"
|
|
db_user="u2"
|
|
db_pass="pass"
|
|
db_name="u2_md5"
|
|
db_table="md5_numbers"
|
|
|
|
# Function to calculate MD5 hash
|
|
calculate_md5() {
|
|
echo -n "$1" | md5sum | awk '{print $1}'
|
|
}
|
|
|
|
# Function to insert values into the database
|
|
insert_into_database() {
|
|
local number=$1
|
|
local md5=$(calculate_md5 "$number")
|
|
mysql -h "$db_host" -u "$db_user" -p"$db_pass" "$db_name" -e "INSERT INTO $db_table (value, md5) VALUES ($number, '$md5');"
|
|
}
|
|
|
|
# Loop from 1 to 10000000 and insert values into the database
|
|
for (( i=13337; i<=10000000; i++ )); do
|
|
insert_into_database "$i"
|
|
# echo "Inserted value $i into database."
|
|
done
|
|
|
|
echo "All values inserted into database."
|
|
|