How to import text file to table with primary key as auto-increment

后端 未结 7 1674
清歌不尽
清歌不尽 2020-12-09 17:29

I have some bulk data in a text file that I need to import into a MySQL table. The table consists of two fields ..

  1. ID (integer with auto-increment)
  2. Na
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 18:26

    Here is the simplest method to date:

    1. Make sure your file does NOT have a header line with the column names. If it does, remove it.
    2. In phpMyAdmin, as usual: go in the Import tab for your table and select your file. Select CSV as the format. Then -- and this is the important part -- in the

    Format-Specific Options:

    ...in the Column names: fill in the name of the column the data is for, in your case "Name".

    This will import the names and auto-increment the id column. You're done!

    Tested fine with phpMyAdmin 4.2.7.1.

提交回复
热议问题