Update error solved: Error SQL Duplicate entry for key 'idx_username'

灰暗的星星灰暗的星星灰暗的星星灰暗的星星灰暗的星星
 
分类:技术文章

Update error solved: Error SQL Duplicate entry for key 'idx_username'

The recent release of Joomla 3.9.16 includes the addition of a database index to the users table. If your Joomla website happens to have duplicate usernames, this index addition will fail and you will see an error as in the attached image. The rest of the update will typically succeed just fine. 

Should you have this error, you must first find and solve the duplicate username problems. Each username in your site should be unique, so you should either rename or remove duplicates. 

To find the duplicates you can run the following MySQL command (replace #_ with the prefix for your tables)

SELECT username FROM #__users GROUP BY username HAVING COUNT(*) > 1

Once you have solved that, then you can navigate to the database fix function and run it to add the missed index. To do that navigate to Extensions > Manage > Database and click the 'Fix' button.

If you experience any issues with this fix, please feel free to get in touch!