/ Duplicate entry '2147483647' for key 'PRIMARY' MySQL Error Solution - rtt - IT Resource

Duplicate entry '2147483647' for key 'PRIMARY' MySQL Error Solution

This usually happens when you are using something like an INT and try to insert a larger value than the maximum which is larger than "2147483647"

On a practical term I have seen this and been guilty of this error when using scripts like PHP and generating large random numbers:

  $hash = mt_rand(5,9999999999999);

Obviously that many 9's are more digits than the maximum of an INT resulting in that error.  Change your code accordingly to avoid the problem:

  $hash = mt_rand(5,2147483647);

 

More info on MySQL INT sizes here.


Tags:

duplicate, entry, primary, mysql, solutionthis, int, insert, larger, maximum, quot, scripts, php, generating, hash, mt_rand, digits, resulting, accordingly, info, sizes,

Latest Articles

  • How Does Cisco CUCM (Cisco Unified Communication Manager) Work?
  • What DNS Options Does Active Directory Offer in Windows Server 2008,2012,2016 ?
  • syntax error, unexpected T_SL in PHP Solution
  • grep regular expression match number range between specific numbers
  • bash how to print out lines of text within a range from the first occurrence
  • bash script how to to check LAN computers for open ports
  • MySQL Using mytop Debug Source of High IO and Slow Performance
  • How To Mathematically Convert and Calculate Binary Value To Decimal Value
  • systemd management using systemctl and journalctl to check systemd logs
  • css how to format code in the code tag
  • css br with extra blank line
  • What is /dev/pts and why do we need it in Linux?
  • Linux What is umask (user mask) for file and directory creation permissions and how to calculate umask and change the defaults
  • Linux Permissions and Groups Real Usecase for Group Access
  • Centos 7 python34 how to install the gi library
  • Centos 7 - Convert Minimal to Graphical GUI GNOME or KDE Desktop
  • AMD Set Fan Speed and Other Powerplay Memory/CPU Timings with a Linux script
  • Ethereum Mining Claymore Nanopool Error
  • genisoimage errors with long filenames and deep directory structures
  • Linux Kernel USB Export Errors