mysql問題處理兩則

aaqwsh發表於2011-05-06

1   mysqlimport  匯入文字亂碼,其實只要保證資料庫、作業系統、文字檔案的字符集一致,應該就不會有亂碼:

 

CREATE TABLE `trinfo` (

  `s_id` varchar(50) NOT NULL,

  `o_code` varchar(255) NOT NULL,

  `t_time` datetime default NULL,

  `eser_id` int(18) default NULL,

  `pid` varchar(4000) NOT NULL,

  `inkeyword` varchar(300) NOT NULL

) ENGINE=MyISAM DEFAULT CHARSET=utf8

 

 

 [root@db mysql]# export LANG='SIMPLIFIED CHINESE_CHINA.UTF-8'

 [root@db mysql]# echo $LANG

SIMPLIFIED CHINESE_CHINA.UTF-8

[root@db mysql]#

[root@db mysql]#

[root@db mysql]# mysqlimport --user=root --password=xxxx --fields-enclosed-by='"' --fields-terminated-by=',' --default-character-set='utf8'  market /var/lib/mysql/tinfo.txt

 

2   Mantis提交BUG時報錯:

Mantis提交BUG時報錯,報錯資訊如下:

 

APPLICATION ERROR #401

資料庫查詢失敗。資料庫返回的錯誤資訊是:#1062: Duplicate entry '5632' for key 1 查詢語句:INSERT INTO mantis_bug_table
( project_id,reporter_id, handler_id,duplicate_id,
priority,severity, reproducibility,status,
resolution,projection, category_id,date_submitted,
last_updated,eta, bug_text_id,
os, os_build,platform, version,build,
profile_id, summary, view_state, sponsorship_total, sticky, fixed_in_version,
target_version, due_date
)
VALUES
( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)

 

首先:select count(*) from mantis_bug_table;

然後:select max(id) from mantis_bug_table;

再 : show create table mantis_bug_table;

發現id值都是正常的,應該是表的字典資訊有問題,導致Duplicate entry '5632' for key 1 , repair table mantis_bug_table解決問題:

 

mysql> select count(*) from mantis_bug_table_tmp;

+----------+

| count(*) |

+----------+

|     5410 |

+----------+

1 row in set (0.00 sec)

 

mysql> select count(*) from mantis_bug_table;

+----------+

| count(*) |

+----------+

|     5410 |

+----------+

1 row in set (0.00 sec)

 

mysql> repair table mantis_bug_table;

+-----------------------------+--------+----------+------------------------------------------+

| Table                       | Op     | Msg_type | Msg_text                                 |

+-----------------------------+--------+----------+------------------------------------------+

| bugtracker.mantis_bug_table | repair | warning  | Number of rows changed from 5410 to 5411 |

| bugtracker.mantis_bug_table | repair | status   | OK                                       |

+-----------------------------+--------+----------+------------------------------------------+

2 rows in set (0.10 sec)

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/758322/viewspace-694606/,如需轉載,請註明出處,否則將追究法律責任。

相關文章