Troubleshooting

Joomla 1.0 and 1.5 with MySQL 8, error with the reserved word "groups"

Reviewed on 3 min read MySQL compatibility Joomla

Joomla 1.0 and 1.5 have gone many years without security updates. This fix is for keeping an old project running while you prepare its migration to a current version, not as a permanent solution.

Problems with an old Joomla usually come from two places. The first is PHP, and it is solved by choosing the PHP version in cPanel that the website needs. The second is MySQL: Joomla 1.0 and 1.5 work fine with MySQL 5.7, but fail with MySQL 8.

Why it fails with MySQL 8

MySQL 8 added new reserved words, words that cannot be used in an SQL query as a column name or alias unless they are enclosed in backticks (`).

In Joomla the problem is the word groups, which used to be allowed and is reserved in MySQL 8. It appears in queries in these files:

components/com_content/models/section.php
components/com_content/models/article.php
components/com_content/models/frontpage.php
components/com_content/models/category.php

The affected queries contain AS groups, for example:

...u.usertype, cc.title AS category, g.name AS groups...

Solution: escape "groups" with backticks

First make a copy of the components/com_content folder (for example, compress it from the cPanel File Manager).

Open each of the files above and put groups in backticks in every match:

...u.usertype, cc.title AS category, g.name AS `groups`...

Save and repeat in all the files. With that, Joomla now works with MySQL 8.

Do it from the terminal

If you have access to the cPanel Terminal or SSH, go to the Joomla folder and find all the files with matches:

find . -name "*.php" -type f -print0 | xargs -0 grep -l 'AS groups'

And fix them all at once:

find . -name "*.php" -type f -exec sed -i 's/g\.name AS groups/g.name AS `groups`/g' {} \;

Run the search again: if any file still shows up, it uses the word with an alias other than g.name. Open it and fix it by hand as above.

Check that it works

Open the home page, a section, a category and an article. If an SQL error still appears, copy the full message: if it mentions another word near near '...', look it up in the list of MySQL 8 reserved words and escape it in the same way. If the error mentions another extension (for example, a third-party component), the fix goes in its files, inside components/ or modules/.

You may also find useful

Something wrong or out of date? Tell us and we will review it.