greglamb
9/23/2016 - 6:37 PM

mysqld

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