Stop mysqld service:
systemctl stop mysqld
Create a /pwd.txt file with following contents:
cat /pwd.txt
ALTER USER 'root'@'localhost' IDENTIFIED BY 'pwd123';
be sure that the /pwd.txt will be accessible by mysql user.mysqld --init-file=/pwd.txt &
Try to login:
mysql -u root -ppwd123
If login succeded kill mysqld running process and start the service:
killall mysqld #several times
systemctl start mysqld