linux里mysql数据库导入数据结构,丢失了索引 解决步骤
1.网上可查 索引导出语句:(导出语句并没将索引导出而是全部查出来)
SELECT
CONCAT('ALTER TABLE `',TABLE_NAME,'` ', 'ADD ',
IF(NON_UNIQUE = 1,
CASE UPPER(INDEX_TYPE)
WHEN 'FULLTEXT' THEN 'FULLTEXT INDEX'
WHEN 'SPATIAL' THEN 'SPATIAL INDEX'
ELSE CONCAT('INDEX `',
INDEX_NAME,
'` USING ',
INDEX_TYPE
)
END,
IF(UPPER(INDEX_NAME) = 'PRIMARY',
CONCAT('PRIMARY KEY USING ',
INDEX_TYPE
),
CONCAT('UNIQUE INDEX `',
INDEX_NAME,
'` USING ',
INDEX_TYPE
)
)
),'(', GROUP_CONCAT(DISTINCT CONCAT('`', COLUMN_NAME, '`') ORDER BY SEQ_IN_INDEX ASC SEPARATOR ', '), ');') AS 'Show_Add_Indexes'
FROM information_schema.STATISTICS
WHERE TABLE_SCHEMA = '数据库名'
GROUP BY TABLE_NAME, INDEX_NAME
ORDER BY TABLE_NAME ASC, INDEX_NAME ASC
2,粘贴到notepad++,使用工具删除里面的 primayr key,(数据结构导出了)
3在linux mysql数据库中添加上面的 非主键 索引
4.查看索引
show index from 表名;
完成!!!!!!!!!!