(may work on other distros especially debian based ones)
Run the following to connect as root
(without any password)
sudo /usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf
If you don't want to add --defaults-file
each time you want to connect as root
, you can copy /etc/mysql/debian.cnf
into your home directory:
sudo cp /etc/mysql/debian.cnf ~/.my.cnf
and then:
sudo mysql