Reset root password on mysql >= 5.7.17

Edit /etc/rc.conf:

mysql_args="--skip-grant-tables --skip-networking"

Restart mysql:

service mysql-server restart

Login like root:

mysql> UPDATE mysql.user SET authentication_string = PASSWORD('aaaa') WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

Remove or comment:

# mysql_args="--skip-grant-tables --skip-networking"

Restart mysql:

service mysql-server restart

mysqldump: Couldn’t execute ‘SHOW VARIABLES LIKE ‘gtid_mode”:

To fix that try this:

# mysql_upgrade -u root -p --force