From b70a99a624f177c2ce0aa28dd826ff4c3e1816d0 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 19 Jan 2010 14:29:32 -0200 Subject: Using just change_mysql_rootpw --- templates/setmysqlpass.sh.erb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 templates/setmysqlpass.sh.erb (limited to 'templates') diff --git a/templates/setmysqlpass.sh.erb b/templates/setmysqlpass.sh.erb new file mode 100644 index 0000000..902336a --- /dev/null +++ b/templates/setmysqlpass.sh.erb @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Set MySQL password. +# + +# Config +SERVICE="/etc/init.d/mysql" +PASSWORD="<%= mysql_rootpw %>" +DATADIR="/var/lib/mysql/data" +LOGBIN="/var/lib/mysql/mysql-bin" +USER="mysql" +GROUP="mysql" +DEFAULTS="/etc/mysql/debian.cnf" + +# Stop service +#$SERVICE stop + +# Start without grant tables +# This seems unsafe as opens a race condition. +#/usr/libexec/mysqld --skip-grant-tables --user=root --datadir=$DATADIR log-bin=$LOGBIN & + +# Wait +#sleep 5 + +# Change root password +echo "USE mysql; UPDATE user SET Password=PASSWORD('$PASSWORD') WHERE User='root' AND Host='localhost';" | \ + /usr/bin/mysql --defaults-file=$DEFAULTS + +# Kill the daemon +#killall mysqld + +# Chown to be on the safe side +#chown $USER.$GROUP $LOGBIN* + +# Start service +#$SERVICE start -- cgit v1.2.3