title: Error altering primary key column in mysql table
body: <p>I am very new to SQL and MySQL. I am trying to modify a primary key column in a table so that it auto-increments. This primary key is also a foreign key in another table. I am not able to modify this column due to an error related to the foreign key in the other table. Here is the error:</p>
  
  <pre><code>mysql&gt; desc favourite_food;
  +-----------+----------------------+------+-----+---------+-------+
  | Field     | Type                 | Null | Key | Default | Extra |
  +-----------+----------------------+------+-----+---------+-------+
  | person_id | smallint(5) unsigned | NO   | PRI | 0       |       |
  | food      | varchar(20)          | NO   | PRI |         |       |
  +-----------+----------------------+------+-----+---------+-------+
  2 rows in set (0.09 sec)
  
  mysql&gt; alter table person modify person_id smallint unsigned auto_increment;
  ERROR 2006 (HY000): MySQL server has gone away
  No connection. Trying to reconnect...
  Connection id:    22
  Current database: bank
  
  ERROR 1833 (HY000): Cannot change column 'person_id': used in a foreign key cons
  traint 'fk_fav_food_person_id' of table 'bank.favourite_food'
  mysql&gt;
  </code></pre>
  
  <p>I'm sure it is something simple, but I can't figure out why and teh book I am following does not indicate why. Thanks.</p>