So to reset the root password, you still start mySQL with –skip-grant-tables options and update the user table, but how you do it has changed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
1. Stop mysql: systemctl stop mysqld 2. Set the mySQL environment option systemctl set-environment MYSQLD_OPTS="--skip-grant-tables" 3. Start mysql usig the options you just set systemctl start mysqld 4. Login as root mysql -u root 5. Update the root user password with these mysql commands mysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword') -> WHERE User = 'root' AND Host = 'localhost'; mysql> FLUSH PRIVILEGES; mysql> quit 6. Stop mysql systemctl stop mysqld 7. Unset the mySQL envitroment option so it starts normally next time systemctl unset-environment MYSQLD_OPTS 8. Start mysql normally: systemctl start mysqld Try to login using your new password: 7. mysql -u root -p |
mysqld_safe is the recommended way to start a mysqld server on Unix. mysqld_safe adds some safety features such as restarting the server when an error occurs and logging runtime information to an error log file. A description of error logging is given later in this section.
Note
As of MySQL 5.7.6, for MySQL installation using an RPM distribution, server startup and shutdown is managed by systemd on several Linux platforms. On these platforms, mysqld_safe is no longer installed because it is unnecessary. For more information, see Section 2.5.10, “Managing MySQL Server with systemd”.
mysqld_safe tries to start an executable named mysqld. To override the default behavior and specify explicitly the name of the server you want to run, specify a –mysqld or –mysqld-version option to mysqld_safe. You can also use –ledir to indicate the directory where mysqld_safe should look for the server.
Many of the options to mysqld_safe are the same as the options to mysqld. See Section 6.1.4, “Server Command Options”.
Options unknown to mysqld_safe are passed to mysqld if they are specified on the command line, but ignored if they are specified in the [mysqld_safe] group of an option file.