Mysql couldn't connect

hi

i have asterisk 1.2.7.1 with mysql configured. it as working fine. i have restarted the machine and started the asterisk.it started well.

"ERROR[5346]: cdr_addon_mysql.c:226 mysql_log: mysql_cdr: Failed to insert into database: (1062) Duplicate entry ‘’ for key 3 "

can you help me to fix the issue?

Thanks in advance

Any help would be much help full

Thanks in advance

[quote=“rizwan”]"ERROR[5346]: cdr_addon_mysql.c:226 mysql_log: mysql_cdr: Failed to insert into database: (1062) Duplicate entry ‘’ for key 3 "
[/quote]

can you establish the SQL it’s trying to run from a debug log ? then use your favourite MySQL query tool to run the same SQL and see what the result is … i suspect you’ll then see where the problem is. have you changed the structure of a CDR db table ? or modified the values or keys ?

i am able to connect locally from the prompt using mysql -u … now i logged in asterisk cli , and seeing

ERROR[6444]: cdr_addon_mysql.c:144 mysql_log: cdr_mysql: cannot connect to database server localhost.

Thanks in Advance

Start MySql in safe mode

mysqld --safe-mode

then check the log for error…

Did you change the password???

i get this error …

[root@phones root]# mysqld --safe-mode
060807 11:40:29 [ERROR] Fatal error: Please read “Security” section of the manual to find out how to run mysqld as root!

060807 11:40:29 [ERROR] Aborting

060807 11:40:29 [Note] mysqld: Shutdown complete

even i did not change the password.

i amable to login locally using mysql -u root -ppassword.

thanks in advance

The mysql error appears to show that the server is running fine and asterisk has no problem sending it sql instructions. In an insert instruction there is a problem since asterisk is trying to send a null value to an as yet unidentified table which has an index which is stopping the append.

You could log in to mysql using the mysql CLI, ‘use’ the asterisk database, do ‘describe’ for each of the tables and check that the report complies with the sql you used to set up the tables in the first place.

Second if you do ‘show indexes from …’ where … is each of the tables in turn, this will show which tables have 3 or more indexes in use, and what they are doing.

hi,

i had 5 indexes, out of this 2 indexes are duplicates for the existing indexes, so i deleted indexes started recording the call details, but i have lost cdr details for the last two days…

is there any to get the cdr for two days?

Thanks in advance

You might want to check /var/log/asterisk/cdr-csv/Master.csv or whatever directory your install is using to store cdr records in plain vanilla csv format. It is possible that the records you need have been stored here and could be inserted into your mysql with an sql statement.

Are you using an application which establishes indexes on your database, or were these put in manually? Might be as well to find out where those indexes came from.

Thanks,

i do not use any application and to use the index. and more i did not create the additional indexes.

Thanks in advance