Skip to content

Instantly share code, notes, and snippets.

@gdm
Created February 15, 2018 22:11
Show Gist options
  • Select an option

  • Save gdm/8cfe936656b8924570db3e5424b72fbf to your computer and use it in GitHub Desktop.

Select an option

Save gdm/8cfe936656b8924570db3e5424b72fbf to your computer and use it in GitHub Desktop.
#!/bin/bash -xe
# for
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
mysql -e "GRANT ALL ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '${PASS}' WITH GRANT OPTION;"
# Tested with Debian + mariadb (EasyEngine v3.7.4)
# Release: 8.7
# Codename: jessie
#
@gdm

gdm commented Nov 5, 2018

Copy link
Copy Markdown
Author

How to fix password (may be broken after some time/upgrade)
SET PASSWORD FOR 'debian-sys-maint'@'localhost' = PASSWORD('plain-text-password from /etc/mysql/debian.cnf');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment