https://blog.csdn.net/qq_35203425/article/details/104012383

https://www.cnblogs.com/cnwcl/p/13805643.html

https://blog.csdn.net/r527665047/article/details/107056941/

https://www.cnblogs.com/py1612919884/p/9327015.html

参考了上面几位大佬的做法。

 

1.因为Ubuntu下有这个账号debian-sys-maint

lee@LAPTOP-ST9BO1FG:/etc/mysql$ sudo cat debian.cnf 
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = 我是打码
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = 46laiRI1j9wwgBKL
socket   = /var/run/mysqld/mysqld.sock

sudo mysql -udebian-sys-maint -p
Enter password:

//进入

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> ALTER user 'root'@'localhost' IDENTIFIED BY '打码';
Query OK, 0 rows affected (0.01 sec)

就可以了

之前试过哪个什么skip-grant-tables实际上不行,出了报错还要重启,重启过程也见上面两个大佬~