Home > Database > Mysql Tutorial > body text

解决MySQL 5.0不能使用自动增加字段问题_MySQL

WBOY
Release: 2016-06-01 14:00:58
Original
881 people have browsed it

问题:MySQL 5.0不能使用自动增加字段。

  具体原因:

  引起的原因是在MySQL5.0.2版本中的The Server SQL Mode 中新加了几种 sql_mode,并且在sql的my.ini文件中的sql-mode 默认增加了其中的二种,一个是STRICT_TRANS_TABLES,就是导致auto_increament失败的mode,这个sql_mode主要用于当一个值不能插入到表中是,则产生一个错误而不是一个警告并终止会话。

  解决办法:

  删除这个sql_mode.重启mysql.

  将my.ini中的:

  # Set the SQL mode to strict
  sql-mode="STRICT_TRANS_TABLES,NO_AUTO_create_USER,NO_ENGINE_SUBSTITUTION"
  改为:
  # Set the SQL mode to strict
  #sql-mode="STRICT_TRANS_TABLES,NO_AUTO_create_USER,NO_ENGINE_SUBSTITUTION"
  sql-mode="NO_AUTO_create_USER,NO_ENGINE_SUBSTITUTION"

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!