For MySQL versions < 5.7:
the default root password should be nothing so just tap enter after:
mysql -u root
You should obviously change your root password after installation
To set a new password do:
mysqladmin -u root password [newpassword]
This should be enough to set you up for the DB Operations
For versions that came after 5.7:
So when you initialize the server, the data directory of the server is empty:
- The server is initialized.
- SSL certificate and key files are generated in the data directory.
- The validate_password plugin is installed and enabled.
- The superuser account 'root'@'localhost' is created. The password for the superuser is set and stored in the error log file.
This generates a temporary password. Use this command to show:
shell> sudo grep 'temporary password' /var/log/mysqld.log
Now change the root password, Use:
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass5!';