Setting root password in fresh mysql 5.7 installation
If you just run mysql command under root user you will be granted access without asked for password, because socket authentication enabled for root@localhost.

This guide is misleading.

The only way to set password is to switch to native authentication like:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';