First of all, make sure the mysql service is running:
ps elf|grep mysql
you will see an output like this if is running:
4 S root 9642 1 0 80 0 - 2859 do_wai 23:08 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/tomcat-machine.local.pid
4 S mysql 9716 9642 0 80 0 - 200986 poll_s 23:08 pts/0 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/tomcat-machine.local.err --pid-file=/var/lib/mysql/tomcat-machine.local.pid
then change localhost to 127.0.0.1 in config.inc.php
$cfg['Servers'][$i]['host'] = '127.0.0.1';
The default password for "root" user is empty "" do not type anything for the password
If it does not allow empty password you need to edit config.inc.php again and change:
$cfg['Servers'][$i]['AllowNoPassword'] = true;
The problem is a combination of config settings and MySQL not running. This was what helped me to fix this error.