系统环境
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
mysql --version
mysql Ver 14.14 Distrib 5.7.26, for Linux (x86_64) using EditLine wrapper
1.修改 /etc/mysql/mysql.conf.d/mysqld.cnf 在[mysqld]下面添加
skip-grant-tables
使用--skip-grant-tables关闭MySQL服务器的认证,从而可以重置root的密码
2.在[mysqld]下添加skip-grant-tables,然后保存并退出
3重启service mysql restart