summaryrefslogtreecommitdiff
path: root/templates/setmysqlpass.sh.erb
blob: 372b513143141bb247527a9fb9ec5c2b0f8c3da4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
#
# Change MySQL root password.
#

# Config
PASSWORD="<%= @rootpw %>"
DEFAULTS="/etc/mysql/debian.cnf"

# Run
/usr/bin/mysql --defaults-file=$DEFAULTS <<EOF
UPDATE mysql.user SET Password=PASSWORD('$PASSWORD') WHERE User='root' AND Host='localhost';
UPDATE mysql.user SET Password=PASSWORD('$PASSWORD') WHERE User='root' AND Host='<%= fqdn %>';
UPDATE mysql.user SET Password=PASSWORD('$PASSWORD') WHERE User='root' AND Host='127.0.0.1';
FLUSH PRIVILEGES;
EOF