From 39758c6344d2e0a70871f5e47f8c124cb49849b8 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 19 Jan 2010 12:09:01 -0200 Subject: Setting root password --- files/setmysqlpass.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 files/setmysqlpass.sh (limited to 'files/setmysqlpass.sh') diff --git a/files/setmysqlpass.sh b/files/setmysqlpass.sh new file mode 100644 index 0000000..586775e --- /dev/null +++ b/files/setmysqlpass.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Set MySQL password. +# + +CONF="/root/.my.cnf" + +# Check config file +if [ ! -e "$CONF" ]; then + echo "File not found: $CONF" + exit 1 +fi + +# Get password from configuration +passwd="`grep ^'password='` $CONF | cut -d '=' -f 2" + +# Set the password +echo "USE mysql; UPDATE user SET Password=PASSWORD('$passwd') WHERE User='root' AND Host='localhost';" | /usr/bin/mysql -u root -- cgit v1.2.3