Using --skip-grant-tables

In this method, you stop the server and start it by specifying --skip-grant-tables, which will not load the grant tables. You can connect to the server as root without a password and set the password. Since the server runs without grants, it is possible for users from other networks to connect to the server. So as of MySQL 8.0.3, --skip-grant-tables automatically enables --skip-networking, which does not allow remote connections:

  1. Stop the server:
shell> sudo systemctl stop mysqldshell> ps aux | grep mysqld | grep -v grep
  1. Start the server with the --skip-grant-tables option:
shell> sudo -u mysql /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid --user=mysql --skip-grant-tablesmysqld will log errors ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.