Skip to content

Instantly share code, notes, and snippets.

@mxyq
mxyq / change_passwd.sh
Last active August 24, 2022 22:08
[MySQL] #Bash #MySQL
config_mysqld() {
_info "Change MySQL Password ..."
db_pass=""
${mysql_location}/bin/mysqld --initialize-insecure --user=mysql >>/var/log/initialize.log 2>&1
${mysql_location}/bin/mysql_ssl_rsa_setup
/usr/local/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${db_pass}\" with grant option;"
/usr/local/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${db_pass}\" with grant option;"
/usr/local/bin/mysql -uroot -p${db_pass} -e "grant all privileges on *.* to root@'%' identified by \"${db_pass}\" with grant option;"
@mxyq
mxyq / detect_os.sh
Last active March 3, 2022 05:45
[Detect OS] #Bash
# Detect OS
# $os_version variables aren't always in use, but are kept here for convenience
if grep -qs "ubuntu" /etc/os-release; then
os="ubuntu"
os_version=$(grep 'VERSION_ID' /etc/os-release | cut -d '"' -f 2 | tr -d '.')
elif [[ -e /etc/debian_version ]]; then
os="debian"
os_version=$(grep -oE '[0-9]+' /etc/debian_version | head -1)
elif [[ -e /etc/almalinux-release || -e /etc/rocky-release || -e /etc/centos-release ]]; then
os="centos"