Смяна на root парола на MySQL5

в : 1337

08.31.07

@ 11:32 PM

от GattaNegra

На тoзи скрипт попаднах благодарение на Google , а ето и оригинала.

#!/bin/bash
#
# resetRootPass script
#
# Recover lost root password of mysql database.
#
#

echo
echo "Mysql password recovery utility"
echo

# Stop the mysql server
/etc/init.d/mysql stop
/etc/init.d/mysql zap > /dev/null
#/usr/bin/killall mysqld > /dev/null
ps aux |grep mysql |awk {'print $2'} | xargs kill -9
# Run mysqld in permissionless mode
/sbin/start-stop-daemon --start --quiet --exec /usr/bin/mysqld_safe \
        --background -- --skip-grant-tables >/dev/null 2>&1

sleep 1

# Execute queries
	mysql -u root mysql -e "UPDATE user SET Password=PASSWORD('$1') WHERE \
	                        user='root'; \
	                        FLUSH PRIVILEGES;"
if [[ $? -eq 0 ]]
then
        echo " ** SQL root password updated"
else
        echo " ** SQL root password update unsuccesful"
fi

# Restart the mysql server
ps aux |grep mysql |awk {'print $2'} | xargs kill -9
/etc/init.d/mysql start

echo "Succesfully updated password!!"
echo
echo
exit 0

добави

Spam protection by WP Captcha-Free