how to connect to the database as root user in linux

Shell
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';mysql -u root -p
Source

Also in Shell: