Skip to content

Instantly share code, notes, and snippets.

@AbhishekGhosh
Created May 23, 2018 19:25
Show Gist options
  • Save AbhishekGhosh/1abc7680b5679510929ae2cf9d1717ef to your computer and use it in GitHub Desktop.
Save AbhishekGhosh/1abc7680b5679510929ae2cf9d1717ef to your computer and use it in GitHub Desktop.
Percona debian-sys-maint
#!/bin/sh
MYSQLADMIN_CFG="/etc/mysql/percona-server.conf.d/90-mysqladmin.cnf"
PASS=$(perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)');
sed -i "s/^password =.*$/password = ${PASS}/" /etc/mysql/debian.cnf
sed -i "s/^user =.*$/user = debian-sys-maint/" /etc/mysql/debian.cnf
umask 066
cat > ${MYSQLADMIN_CFG} <<EOF
[mysqladmin]
host = localhost
user = debian-sys-maint
password = ${PASS}
socket = /var/run/mysqld/mysqld.sock
EOF
umask 022
chown 0:0 ${MYSQLADMIN_CFG}; chmod 0600 ${MYSQLADMIN_CFG}
# update credentials
mysql -u root -p -e "GRANT ALL ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '${PASS}' WITH GRANT OPTION;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment