Can't connect to MySQL server on '127.0.0.1' (111)

Hi all,
I’m a newbie to nagios but have some experience on MySQL.
I’d like to monitor mysql database on localhost (ie nagios and MySQL are on the same server) but this fails.

System description:
[list]OS is CentOS 5.2[/list:u]
[list]MySQL is 5.0.45[/list:u]
[list]Nagios Version is 3.0.6 installed via yum.[/list:u]
[list]Nagios Plugin is check_mysql v2034 (nagios-plugins 1.4.13)[/list:u]

First of all I did the following:
[list=]added to commands.cfg the following:[/list]

[code]################################################################################

MySQL

################################################################################

‘check_mysql’ command definition

define command{
command_name check_mysql
command_line $USER1$/check_mysql -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$
}[/code]
[list=]added to localhost.cfg the following:[/list]

# Define a service to check MySQL on the local machine. define service{ use local-service ; Name of service template to use host_name localhost service_description MySQL check_command check_mysql!localhost!root!passwd notifications_enabled 0 }
[list=]Restarted nagios without errors[/list]
As of this configuration nagios shows the following:
[list=]Can’t connect to MySQL server on ‘127.0.0.1’ (111)[/list]
I made the following to troubleshoot:
Check MySQL permissions (table users in mysql database), and the root user appears in two identical records except for the Host column, that contains

and

.
So I guess that MySQL configuration is ok, right?
After this I tried to execute the chek_mysql from command line. Below the results:

[root@localhost]# ./check_mysql -H 127.0.0.1 -u root -p passwd Can't connect to MySQL server on '127.0.0.1' (111) [root@localhost]# ./check_mysql -H localhost -u root -p passwd Uptime: 3675 Threads: 4 Questions: 4441 Slow queries: 0 Opens: 115 Flush tables: 1 Open tables: 64 Queries per second avg: 1.208
Maybe this is related to the /etc/hosts file?
Here is mine:

[code][root@localhost]# cat /etc/hosts

Do not remove the following line, or various programs

that require network functionality will fail.

127.0.0.1 localhost[/code]

Does anybody faced such problem? Can anyone help?
Thanks in advance,
Evan

I made the following change in command.cfg and now it works!!!

# 'check_mysql' command definition define command{ command_name check_mysql command_line **$USER1$/check_mysql -H $ARG1$ -u $ARG2$ -p $ARG3$** }

But I can’t understand why it doesn’t work properly in the previous form:

Does anybody has a good explanation about this?

Thanks,
Evan