cdr_mysql.c: Failed to connect to mysql database asterisk

I’m running Asterisk SVN-branch-11-r401960. I have notice that every time i turn off my Asterisk server and then i turn it back on on the next day is not saving the CDR in MYSQL DB

The problem occur too if i reboot the machine.

On the logs this is the error :[quote]
[Nov 3 17:50:37] ERROR[885] cdr_mysql.c: Failed to connect to mysql database asterisk on 127.0.0.1.[/quote]

But if i execute the Asterisk reload command o restart the Asterisk service,it work intermediately . Any idea?