尝试这个:
mysql -u root -h 127.0.0.1 -pEnter password: (enter the random password here)
参考:https : //dev.mysql.com/doc/refman/5.7/en/data-
directory-initialization-
mysqld.html
之后,您可以使用
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-password';

尝试这个:
mysql -u root -h 127.0.0.1 -pEnter password: (enter the random password here)
参考:https : //dev.mysql.com/doc/refman/5.7/en/data-
directory-initialization-
mysqld.html
之后,您可以使用
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-password';