Skip to content

Instantly share code, notes, and snippets.

@greglamb
Created September 23, 2016 18:37
Show Gist options
  • Select an option

  • Save greglamb/03a14433f065c71eac59f6d86e1371a9 to your computer and use it in GitHub Desktop.

Select an option

Save greglamb/03a14433f065c71eac59f6d86e1371a9 to your computer and use it in GitHub Desktop.
mysqld
#!/bin/bash
systemctl stop mysqld
/usr/sbin/mysqld --skip-grant-tables --user=mysql &
sleep 10
echo "update mysql.user set authentication_string=password('') where user='root';" | mysql
echo "FLUSH PRIVILEGES;" | mysql
PID=`ps -ef | grep skip-grant-tables | grep -v grep | awk '{print $2}'`
while [ "$PID" != "" ];do
kill "$PID"
PID=`ps -ef | grep skip-grant-tables | grep -v grep | awk '{print $2}'`
sleep 1
done
systemctl start mysqld
mysql_secure_installation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment