MySql, how can I export indexes from my development database to my production database?

前端 未结 6 746
南方客
南方客 2020-12-11 00:59

I\'ve been working on my development database and have tweaked its performance.

However, to my surprise I can\'t find a way to export the indexes to my production da

6条回答
  •  萌比男神i
    2020-12-11 01:46

    I also have development and production servers with the same database structure.

    I modified indexes on both of them so I wanted to merge all together. So I needed to compare data with Notepad+.

    Here is how you export indexes for all tables, all databases and how to filter and compare them:

    --- Single table:
        SHOW INDEX FROM mydb.mytable;
        SHOW INDEX FROM mytable;
    
    --- Multi tables, databases:
        USE information_schema;
        SELECT * FROM `statistics` ORDER BY TABLE_SCHEMA ASC, TABLE_NAME ASC, INDEX_NAME ASC;
    

    Now, phpMyAdmin -> Export to CSV-Excel:

    add a header row -> delete all columns but leave "database_name table_name index column value"

    Then, filter by database.

    Copy all from database1 to a notepad+ screen 1, filter excel database2, copy all to notepad+ screen 2 -> COMPARE!

提交回复
热议问题